Home | Ajax | BioInformatics | Dojo | EAI | EJB | Hibernate | J2ME | Java | Java Glossary | Java Servlets | JavaScript | Jboss | JDBC | JDO | Jmeter | JSF | JSP | JUnit | Maven | MySQL | Spring Framework | SQL | Struts | Technology | WAP | Web Services | XML


 
  
 
Programming Tutorials: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML
 

 
Facing Programming Problem?
Ask Questions?, Browse Latest Questions, Question-Answer Guidelines
JSP
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments

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.


 

                          

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 
Latest Searches:
getServletContext().se
2d array
jQuery To Hide the Div
char at
java program to create
jpanel
show input box
disable minimize butto
org/apache/commons/lan
validate user input in
clear the screen in ja
writing ByteArray into
two dimensional array
format decimal left ju
web service hibernat
save file name
using wrapper conversi
setvisible tab
jsp action tags
assemply language
getcolumns()
left justify
spring framework
graphics in c programi
java thread
ASP 3.0
createSQLQuery exampl
create a moving banner
pseudocode of magic sq
how to run a servlet f
array examples
tell me about yourself
count the number of di
LinkedPane in dojo
RADTutorials
File InputStream
tables pdf itext
GWT Servlet
how to get the time di
validate javascript
hiding frame in jsp
concert cm to inches
passing values from js
actionlistener
java loop pass count
learnjavainoneday
binary recursio
java read from file
Reading a File into st
Convert Integer to Flo
saveOrUpdate faces
<logic:match name
welcome page
webservice
types
iterator
killing a thread
reflection api
HSSFHeader
String Tokenizer
6.How
how to retrieve databa
video streaming UD
datatable
Use of <x:set> tag of
JSF signout out
DefaultMutableTreeNode
Photoshop Effects Grun
view the result of jme
newline character
php xml
Collection in java
rules to use java col
set cell value JTable
Declaring java technol
validate action class
digital clock in java
copy multiple lines fr
clear values from a fo
JLabel
Java String toLowerCase Example
Java String toCharArray Example
Java String substring Example
Java String indexOf Example
Java String startsWith Example
Java String hashCode Example
Java String matches Example
Java String length Example
Java String lastIndexOf Example
Java String isEmpty Example
Java String equalsIgnoreCase Example
Java String equals Example
Java String endsWith Example
Java String copyValueOf Example
Java String contentEquals Example
  EAI Articles
  Java Certification
Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

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

Indian Software Development Company | iPhone Development Company in India | Java Training Delhi | Java Training at Noida |

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

Copyright © 2008. All rights reserved.