Tuesday 28 February 2017

servlet tutorial

sendRedirect


The sendRedirect() method of HttpServletResponse interface can be used to redirect response to another resource, it may be servlet, jsp or html file. It accepts relative as well as absolute URL.

servletConfig


An object of ServletConfig is created by the web container for each servlet. This object can be used to get configuration information from web.xml file.

servletContext


An object of ServletContext is created by the web container at time of deploying the project. This object can be used to get configuration information from web.xml file. There is only one ServletContext object per web application.

servletAttribute


An attribute in servlet is an object that can be set, get or removed from one of the following scopes:
1-request scope
2-session scope
3-application scope

cookie part1


A cookie is a small piece of information that is persisted between the multiple client requests. A cookie has a name, a single value, and optional attributes such as a comment, path and domain qualifiers, a maximum age, and a version number.

cookie part2 eclipse example


A cookie is a small piece of information that is persisted between the multiple client requests. A cookie has a name, a single value, and optional attributes such as a comment, path and domain qualifiers, a maximum age, and a version number.

login logout using cookie


A cookie is a kind of information that is stored at client side. In the previous page, we learned a lot about cookie e.g. how to create cookie, how to delete cookie, how to get cookie etc. Here, we are going to create a login and logout example using servlet cookies. In this example, we are creating 3 links: login, logout and profile. User can't go to profile page until he/she is logged in. If user is logged out, he need to login again to visit profile.

urlRewriter


In URL rewriting, we append a token or identifier to the URL of the next Servlet or the next resource. We can send parameter name/value pairs using the following format:
url?name1=value1&name2=value2&??

httpSession


container creates a session id for each user.The container uses this id to identify the particular user.An object of HttpSession can be used to perform two tasks:
1-bind objects
2-view and manipulate information about a session, such as the session identifier, creation time, and last accessed time.

No comments:

Post a Comment