File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Sessions JSP,JavaBeans and Servlets, Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Sessions JSP,JavaBeans and Servlets," Watch "Sessions JSP,JavaBeans and Servlets," New topic
Author

Sessions JSP,JavaBeans and Servlets,

Shuaib Gill
Ranch Hand

Joined: May 29, 2001
Posts: 62
How can I include sessions in JSP, Java Beans and Servlets?
I am using JSP model 2 architecture to seperate business logic from presentation.
using MVC (Model(java bean) View(jsp) Control(servlet))


programmer77
Marcos Maia
Ranch Hand

Joined: Jan 06, 2001
Posts: 977
At jsp:
<%@ page session="true"%>
or if you don�t want to create one
<%@ page session="false"%>
note that the true value is the default and if you wanna use a session in your jsp you don�t have do do nothing
at servlets:
HttpSession s = request.getSession(true);
this command creates a new session if one already is not created and if so just recovers the session.

HttpSession s = request.getSession(false);
this command recovers a session already created but if one doesn�t exist don�t create one.

and you can use:
setAttribute(String name, Object value);
to bind your javabeans to the session
and then recover them with:
getAttribute(String name);
and don�t forget to cast it back to it�s type.
 
wood burning stoves
 
subject: Sessions JSP,JavaBeans and Servlets,
 
Similar Threads
Information about OCPJWCD 6 / SCWCD 6 [CX-310-085]
Java Beans and JSP
beans & jsp
Cache Strategy
Caching pages