Found 177 Articles for JSP

What methods of session object is used frequently in JSP and for what purpose?

Chandu yadav
Updated on 30-Jul-2019 22:30:25

193 Views

Here is a summary of important methods available through the session object −Sr.No.Method & Description1public Object getAttribute(String name)This method returns the object bound with the specified name in this session, or null if no object is bound under the name.2public Enumeration getAttributeNames()This method returns an Enumeration of String objects containing the names of all the objects bound to this session.3public long getCreationTime()This method returns the time when this session was created, measured in milliseconds since midnight January 1, 1970 GMT.4public String getId()This method returns a string containing the unique identifier assigned to this session.5public long getLastAccessedTime()This method returns the last ... Read More

How can we maintain session between Web Client and Web Server?

Arjun Thakur
Updated on 30-Jul-2019 22:30:25

1K+ Views

Following are the few options to maintain the session between the Web Client and the Web Server −CookiesA webserver can assign a unique session ID as a cookie to each web client and for subsequent requests from the client they can be recognized using the received cookie.This may not be an effective way as the browser at times does not support a cookie. It is not recommended to use this procedure to maintain the sessions.Hidden Form FieldsA web server can send a hidden HTML form field along with a unique session ID as follows −This entry means that, when the ... Read More

What is the use of Cookie or hidden fields in JSP?

Ankith Reddy
Updated on 30-Jul-2019 22:30:25

443 Views

CookiesA webserver can assign a unique session ID as a cookie to each web client and for subsequent requests from the client they can be recognized using the received cookie.This may not be an effective way as the browser at times does not support a cookie. It is not recommended to use this procedure to maintain the sessions.Hidden Form FieldsA web server can send a hidden HTML form field along with a unique session ID as follows −This entry means that, when the form is submitted, the specified name and value are automatically included in the GET or the POST ... Read More

What is the session Object in JSP?

George John
Updated on 30-Jul-2019 22:30:25

3K+ Views

The session object is used to track a client session between client requests.JSP makes use of the servlet provided HttpSession Interface. This interface provides a way to identify a user across.a one-page request orvisit to a website orstore information about that userBy default, JSPs have session tracking enabled and a new HttpSession object is instantiated for each new client automatically. Disabling session tracking requires explicitly turning it off by setting the page directive session attribute to false as follows −The JSP engine exposes the HttpSession object to the JSP author through the implicit session object. Since the session object is ... Read More

What is the difference between JspWriter and PrintWriter?

Chandu yadav
Updated on 30-Jul-2019 22:30:25

116 Views

The JspWriter object contains most of the same methods as the java.io.PrintWriter class. However, JspWriter has some additional methods designed to deal with buffering. Unlike the PrintWriter object, JspWriter throws IOExceptions.

What is the out implicit object in JSP?

Arjun Thakur
Updated on 30-Jul-2019 22:30:25

362 Views

The out implicit object is an instance of a javax.servlet.jsp.JspWriter object and is used to send content in a response.The initial JspWriter object is instantiated differently depending on whether the page is buffered or not. Buffering can be easily turned off by using the buffered = 'false' attribute of the page directive.The JspWriter object contains most of the same methods as the java.io.PrintWriter class. However, JspWriter has some additional methods designed to deal with buffering. Unlike the PrintWriter object, JspWriter throws IOExceptions.Following table lists out the important methods that we will use to write boolean char, int, double, object, String, ... Read More

What is a response object in JSP?

Ankith Reddy
Updated on 30-Jul-2019 22:30:25

935 Views

The response object is an instance of a javax.servlet.http.HttpServletResponse object. Just as the server creates the request object, it also creates an object to represent the response to the client.The response object also defines the interfaces that deal with creating new HTTP headers. Through this object, the JSP programmer can add new cookies or date stamps, HTTP status codes etc.The response object methods can be used to set HTTP response header in your servlet program. This object represents the server response.Following example would use setIntHeader() method to set Refresh header to simulate a digital clock −       ... Read More

Can somebody explain the HTTP headers in simpler terms in JSP context?

George John
Updated on 30-Jul-2019 22:30:25

115 Views

When a Web server responds to an HTTP request, the response typically consists of a status line, some response headers, a blank line, and the document. A typical response looks like this −HTTP/1.1 200 OK Content-Type: text/html Header2: ... ... HeaderN: ... (Blank Line) ... ... The status line consists of the HTTP version (HTTP/1.1 in the example), a status code (200 in the example), and a very short message corresponding to the status code (OK in the example).Following is ... Read More

How to write a while loop in a JSP page?

Samual Sam
Updated on 30-Jul-2019 22:30:25

984 Views

Following is the while loop example −           WHILE LOOP Example                           JSP Tutorial                           The above code will generate the following result −JSP Tutorial JSP Tutorial JSP Tutorial

Which methods can be used to read HTTP header in your JSP program.

Chandu yadav
Updated on 30-Jul-2019 22:30:25

254 Views

The request object provides methods to get HTTP header information including form data, cookies, HTTP methods, etc.Following table lists out the important methods that can be used to read HTTP header in your JSP program. These methods are available with HttpServletRequest object which represents client request to webserver.Sr.No.Method & Description1Cookie[] getCookies()Returns an array containing all of the Cookie objects the client sent with this request.2Enumeration getAttributeNames()Returns an Enumeration containing the names of the attributes available to this request.3Enumeration getHeaderNames()Returns an enumeration of all the header names this request contains.4Enumeration getParameterNames()Returns an enumeration of String objects containing the names of the ... Read More

Advertisements