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

JSP: View Session

                          

The view consists of the Html page or the jsp components that provide the user interface. View is what we see. It is mainly for presentation.

Java Bean: - It is a reusable component. It contains the setter and getter methods to set and get the values from the jsp page or database.

In session whenever a request comes for any resource, a unique token is generated by the server and transmitted to the client by the response object and stored on the client machine as a cookie. We can also say that the process of managing the state of a web based client is through the use of session IDs. Session IDs are used to uniquely identify a client browser, while the server side processes are used to associate the session ID with a level of access. Thus, once a client has successfully authenticated to the web applicatiion, the session ID can be used as a stored authentication voucher so that the client does not have to retype their login information with each page request.

In this program we are using the java Beans to set the values from the html page and set it to the jsp page which will works like a controller.
setAttribute(): is used to set the object. A key is set to look up the object. 
getAttribute(): is used to get the object.

The code of the program is given below:

<html>
	<head>
		<title>View and Session</title>
	</head>
	<body>
		<form method = "get" action = "JspAndSessionJsp.jsp">
		Enter your first Name : <input type = "text" name = "firstName"><br>
		Enter your last Name  : <input type = "text" name = "lastName"><br>
		Enter your email      : <input type = "text" name = "email"><br>
		Enter the address      : <input type = "text" name = "address"><br>
		<input type = "submit" name = "submit" value ="submit"><br>
		</form>
	</body>
</html>

 

package Mybean;
public class JspAndSession{
	private String firstName;
	private String lastName;
	private String email;
	private String address;
	public String getFirstName() {
		return firstName;
	}
	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}
	public String getLastName() {
		return lastName;
	}
	public void setLastName(String lastName) {
		this.lastName = lastName;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	public String getEmail() {
		return email;
	}
    public void setEmail(String email) {
		this.email = email;
	}
}

 

<%@ page import = "Mybean.JspAndSession"%>
<html>
	<body>
		<h1>Your Request</h1>
		Here is the information that you submitted to us for processing.<br>
		<%
		  JspAndSession jas = new JspAndSession();
             jas.setFirstName(request.getParameter("firstName"));
			 jas.setLastName(request.getParameter("lastName"));
			 jas.setEmail(request.getParameter("email"));
			 jas.setAddress(request.getParameter("address"));
		%>
		<% session.setAttribute("jas",jas ); %>
		<a href = "JspSessionView.jsp">Click Here to go forward</a>
	</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 

Current Comments

2 comments so far (
post your own) View All Comments Latest 10 Comments:

please give names to that code for under standing of which code is which name.

Posted by rajesh on Tuesday, 01.29.08 @ 15:45pm | #46490

it seems som jsp is missing to show session values in the last jsp

Posted by rahul on Wednesday, 06.6.07 @ 23:52pm | #18436

Latest Searches:
hexadecimal to binary
Why should exception h
UML with Enterprise Ar
display blob in stuts
Struts 2 Validation Ex
struts html:options
Request Object In JSP
à¹?à¸??à¹?à¸??à¹?à¸??à
java float precision
த���?த��
J2ee
ä»??é?«??ä»??é?«???ä»?
create menubar
Photoshop Textures and
Combattons la programm
jsf frames
jreport designer
ServletContextAttribut
faqs
visual
Photoshop Effects Real
breakÑ?â?£?Ñ?â???Ñ?â??
first write and then r
spring eclipse tutoria
on clikck radio struts
how to retrieve data f
auto update in configu
sum of array
catch keyword
wrapper class
ajax
insert data to text fi
Flash Special Effects
Flash The Toolbar Tuto
getter setter methods
jdbc connectivity usin
find out factors of nu
settext
myfaces tomahawk
distinguish between Re
point of sale
Ajax with JSP
<html:
How to show expression
ASP.NET .NET Add text
Photoshop Photo Effect
?Ñ?â??г??Ñ?â??вÑ?â??
covert uppercase to lo
create file folder alo
syntax
tiles
similarity transform
aaa
Mylyn
types of hibernate
jsp login validation
change password using
j2ee tutorial
jsp validation
POI
how to create tree usi
jasper report
simialarity transform
java jtable
radio in jsp
rmi

spring eclipse
Writing more than one
count the numbet of di
breakÑ?â??â??Ñ?â???Ñ?â
java precision
String indexOf(String
websphere
advantages of jsp over
array example
abstract codes
hibernet
class system
Flash Actionscripting
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.