Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions? | Software Development
 

Session Using URLRewriting

URLRewriting can be used in place where we don't want to use cookies.

Session Using URLRewriting

                          

URLRewriting can be used in place where we don't want to use cookies. It is used to maintain the session. Whenever the browser sends a request then it is always interpreted as a new request because http protocol is a stateless protocol as it is not persistent. Whenever we want that out request object to stay alive till we decide to end the request object then, there we use the concept of session tracking. In session tracking firstly a session object is created when the first request goes to the server. Then server creates a token which will be used to maintain the session. The token is transmitted to the client by the response object and gets stored on the client machine. By default the server creates a cookie and the cookie get stored on the client machine.

URLRewriting can be used where we the cookies are disabled. Its a good practice to use URL Rewriting. In URLRewriting a string is appended

Code of the program is given below:

<html>
	<head>
		<title>How to use encodeURL in jsp</title>
	</head>
	<body>
		<form method = "post" action = "EncodeURLProgram.jsp">
		<font size = 6>Enter your name  : 
<input type = "text" name = "name"></font><br><br> <font size = 6>Enter your password :
<input type="password" name = "pwd" ></font><br><br> <input type = "submit" name = "submit" value = "submit" > </form> </body> </html>

 

<%@ page session ="true" %>
<%  
    String name = request.getParameter("name");
	String password = request.getParameter("pwd");
	if(name.equals("Williams") && password.equals("abcde"))
	{
		session.setAttribute("username",name);
		String string = response.encode
URL("NextPageAfterFirst.jsp?name=+name+&password=+password"); %> <font size = 6><p>Please click here to go forward : </p></font> <font size = 8><a href ='<%= string %>'>WelcomeEncodeURL.jsp</a></font> <%} else { String string = response.encode
URL("encodeURL.jsp?name=+name+&password=+password");%> <font size = 6><p>You have entered a wrong
value : Click here to go back : </p></font> <font size = 6><a href ='<%= string %>'>encodeURL.jsp</a></font> <% } %>

 

<html>
	<head>
		<title>Welcome in In the program of URL rewriting</title>
	</head>
	<body>
<font size = 6>Hello</font> <%= session.getAttribute("username") %>
	</body>
</html>

The output of the program is given below:

When the value are correct:

On clicking the WelcomeEncodeURL.jsp the result will be.

If the value is incorrect:

The output will be again the encodeURL.jsp

Download this example.


 

                          

» View all related tutorials
Related Tags: html c com jsp ide interface io view components user page vi component int id nsis ai js for ie

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
 
Tell A Friend
Your Friend Name

 

 
Recently Viewed
Software Solutions
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.