URL Re-writing is a technique by which session data can be handled within the server side only.Client is not responsible for keeping any information regarding session. In this process at every request the required session data is appended to the URL path to make the next request. All session information is retrieved by the web Server as a request parameter.

There is a way by which session data get appended to the URL path is by
1. Using Query String

Using Query String
A Complete URI is the combination of context path + Servlet path + path info . Query String is appended after Requested URI with the " ? " symbol containing name and value pair.

For example :
http://localhost:9999/myApp/loginServlet?name=xyz&pass=123&.........

In the above example is a complete URL under this,

localhost      ->  Server name
9999           ->  Port Number
/myApp       ->  Context path
/loginServlet ->  Servlet path
jsessionid="" -> Query String.

Value of jsessionid can be retrieved in the servlet  using the getParameter(String) method with the HTTP request object.

Note: Session ID is appended to the URI using the HTTP GET method request type, which allows to send small data with the request in the form of Query String and hence restricted to maximum 255 character. So with Query we are appending client's session information with every request to maintain the clients activity with each proceeding request.

This is how all the session data can be passed to a servlet/jsp with the URL using GET request type from a jsp page.

If we want to transfer the session data from a servlet to another using URL rewriting then we have to use hyperlink and append the same in the url using the " ? " symbol and can able to get the value using the getParameter(String) .

Advantage of URL Rewriting 

1. Doesn't depend on client to store client's session information.

Disadvantages of URL Rewriting

1. Every we need to pass the value as a query string produces heavy loads to the traffic.

2. Through GET method type maximum 255 characters are allowed to pass, it would not be possible it passing parameters exceeds 255 characters.

3. Visible with very request with the request URL. So it may cause security issue and hence not secure.

4. It works only when every page is dynamically generated that means cannot be possible with the html.

5. Passing jsessionid as a Query String needs some Javascript code to submit the form, otherwise it is not possible with the general form submission.

6. It is only possible with GET method type and hence cannot with POST method type.

7. very difficult to maintain the required session data with each proceeding request by the client.

Related Posts:

  • RequestDispatcher with ServletContext We can get the RequestDispatcher object with the ServletContext simpley by calling getRequestDispatcher(String url) with the ServletContext object which finally returns the RequestDispatcher object. We have two possible opt… Read More
  • RequestDispatcher Interface in Servlet RequestDispatcher is an interface which has two important abstract methods defined. 1. include() 2.  forward() Both the methods are used to delegates the control from one Servlet to another Servlet / JSP or from one JS… Read More
  • ServletConfig Object in Servlet ServletContext object is common to all the servlet but ServletConfig object is different for all the servlets and must be created at the time of container start-up for every Servlet. ServletConfig object of one servlet is a… Read More
  • ServletContext Object in Servlet ServletContext is only a single object to a whole Servlet Application. It is once created and initialized by the web container at the container start-up. A Web application has many Servlet classes and for every servlet… Read More
  • HttpSession Object in Servlet In servlet we are getting the session Object in terms of HttpSession by calling getSession() method with the HttpServletRequest object. What is a session ? Session is a object which uniquely identifies the active user so t… Read More

0 comments:

Post a Comment

Ads 468x60px

.

Ads

.

Featured Posts

Popular Posts

Like Us On FaceBook

Total Pageviews

Online Members

Live Traffic