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

Preventing the creation of a Session in a Jsp Page

                          

In jsp we have been provided the implicit session object. In jsp the session is by default true, if we don't declare a session =  "true" inside the directive, then the session is still available as it is by default true. There is not any such use to declare a session false, but to learn just imagine if we declare a session = "false", then what will happen. 

For check this make one jsp page or html page where we have given two field, one is of name and the second one is of password. Now make  a controller which will control the request and response object. Declare the session as false in the page, it will be declared inside the directive. We will try to retrieve the values of the field by using the request.getParameter(), request is the implicit object which has been provided to us by the jsp and the getParameter() is the method of request object. We can see that by declaring the session as false the values will not be able to retrieved by the controller. It will throw a exception.

The code of the program is given below:

<html>
	<head>
		<title>Welcome </title>
	</head>
	<body>
		<form method = "post" action = "SessionLess.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="false"%>
<%  
    String name = request.getParameter("name");
	String password = request.getParameter("pwd");
	if(name.equals("Williams") && password.equals("abcde"))
	{
		session.setAttribute("username",name);
		response.sendRedirect("NextPageOfSessionLess.jsp");
	}
	else
	{
		response.sendRedirect("NoSession.html");
	}
	%>

 

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

The output of the program is given below:

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:
Copy One Database Tabl
struts select
java arrays
check character
Eclipse 3.4 EJB
scalar
how to arrange strings
date validation in jav
jsp MENU SELECT MAKES
inserting records of r
Use of <fn:substringBe
Java date format
java application code
sample program for mar
how to disable the tex
blinking text
Ñ?одÑ?п?Ñ?о???Ñ?о
The Jakarta-Taglibs: D
conditionally hide tab
oracle
java cancel button
insert image in databa
document javascript
if-else-then
java sorting alphabeti
toupload and insert vi
standered jar to downl
export to excel
3DS MAX Modeling The p
use bean
read file
count the numbet of di
Display Data from Data
â???â????â???Ñ???â???â
ASP.NET .NET Inside AS
write a xml file using
ArrayList
sip
dynaactionform
Sql server through jsp
Accessing SQL Server D
break
web.xml tutorial
Tomcat deploy JSP
Combattons la programm
convert string array t
Combo Box operation in
ClassPathXmlApplicatio
ั?ะ�?ั?ะ�?
extract a piece of dat
Create a bar chart in
Test Driven Developmen
EJB bean with annotati
registration connect t
ServletContextAttribut
swing frame with menu
java threads
mobile testing
value change listener
how to read xml file i
Flash Special Effects
à¹??à¸?à¹???à¹??à¸??à¹
dojo chart
jsps in flex
Java Tu
??????????????????????
jms tutorial
Jigloo SWT/Swing GUI B
jreport designer
dwr reverse ajax
Flash Animation Animat
Initialization
drop down in jsp
?Ñ?â??г??Ñ?â??вÑ?â??
usebean tag in jsp
ibats tutorial
object cloning
j2me combo
program in java to dis
web service hibernat
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.