useBean

package com.ourownjava.jsp.bean; /** * @author ourownjava.com */ public class User { private String firstName; private String lastName; public String getFirstName() { return firstName; } public void setFirstName(final String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(final String lastName) { this.lastName = lastName; } } <%@ page […]
Continue reading…

 

Life Cycle

The JSP/Servlet container is responsible for managing the life cycle of a JSP file. In general there are three important stages in JSP life cycle. Instantiation Request Processing Destruction JSP Life Cycle – Initialization Stage When a JSP/Servlet container receives request for a JSP it checks if the JSP is initialized. If the JSP is […]
Continue reading…

 

Post Request

HTML page to make a get request (github) <html> <body> <form action=”jsp-get-method-query-string.jsp” method=”POST”> Who: <input type=”text” name=”who” /> <input type=”submit” value=”Submit” /> </form> </body> </html> JSP page to extract get request parameter (github) <%@ page language=”java” contentType=”text/html; charset=UTF-8″ pageEncoding=”UTF-8″%> <!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”> <html> <head> <meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″> <title>ourownjava.com</title> </head> […]
Continue reading…

 

Get Request – HTML Form

HTML page to make a get request (github) <html> <body> <form action=”jsp-get-method-query-string.jsp” method=”GET”> Who: <input type=”text” name=”who” /> <input type=”submit” value=”Submit” /> </form> </body> </html> JSP page to extract get request parameter (github) <%@ page language=”java” contentType=”text/html; charset=UTF-8″ pageEncoding=”UTF-8″%> <!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”> <html> <head> <meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″> <title>ourownjava.com</title> </head> […]
Continue reading…

 

Get Request – URL Query String

How to access get request parameter in jsp? (github) <%@ page language=”java” contentType=”text/html; charset=UTF-8″ pageEncoding=”UTF-8″%> <!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”> <html> <head> <meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″> <title>ourownjava.com</title> </head> <body> Who : <%=request.getParameter(“who”)%> </body> </html> How to run the sample program? http://localhost:8080/jsp-play-ground/jsp-get-method-query-string.jsp?who=ourownjava.com
Continue reading…

 

session

The JSP implicit object ‘session’ is used to track user session between user requests. JSP implicit object ‘session’ example program (github) <%@ page language=”java” contentType=”text/html; charset=UTF-8″ pageEncoding=”UTF-8″%> <!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”> <html> <head> <meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″> <title>ourownjava.com</title> </head> <body> <!– jsp implicit object request example –> Tomcat implementation of jsp […]
Continue reading…

 

response

The JSP implicit response object contains the output to the client. The JSP implicit response object can be used for following. To add HTTP headers To create cookies To setting content type To redirect JSP implicit object ‘response’ example program (github) <%@ page language=”java” contentType=”text/html; charset=UTF-8″ pageEncoding=”UTF-8″%> <!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”> […]
Continue reading…

 

request

how to access jsp implicit object request in jsp page? <% out.println(request.getParameter(“who”)); %> JSP implicit object pageContext example program (github) <%@ page language=”java” contentType=”text/html; charset=UTF-8″ pageEncoding=”UTF-8″%> <!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”> <html> <head> <meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″> <title>ourownjava.com</title> </head> <body> <!– jsp implicit object request example –> Tomcat implementation of […]
Continue reading…