Showing posts with label getParameter. Show all posts
Showing posts with label getParameter. Show all posts

October 07, 2013

How to redirect to second page from first page through servlet

Servlet Mapping example in deployment descriptor


This java server page (jsp) example shows how to redirect from a page another page in jsp, the request from jsp page will pass through a servlet and from the servlet to second . the following java code will decide which page the request should be directed : page.response.sendRedirect("secondPage.jsp");

web.xml file



<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>Artificial intelligence</display-name>
  <welcome-file-list>
    <welcome-file>newPage.jsp</welcome-file>
  </welcome-file-list>
  <servlet>
    <description>An example for servlet mapping in jsp servlet</description>
    <display-name>Beyonce superbowl</display-name>
    <servlet-name>Beyonce</servlet-name>
    <servlet-class>com.NeuralNetwork.servlet.EvasiOn</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>Beyonce</servlet-name>
    <url-pattern>/NeuralNetwork.jsp</url-pattern>
  </servlet-mapping>
</web-app>



January 04, 2013

JSTL : Java Standard Tag Library

Alternate Solution for JSP tags in JSTL




Jstl equivalent for ('<%=request.getParameter("id")%>') :: ${param.id} and ${param.["id"]}

Jstl equivalent for  session :: ${sessionScope.Object.variableName}


You need to add the jstl jar to your project, Before using the above codes

Download link

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

To know How to use jstl inside your web application click here

http://belazy.blog.com/

Facebook comments