File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Save session inside a Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Save session inside a Servlet" Watch "Save session inside a Servlet" New topic

Save session inside a Servlet

Isaac Ferguson
Ranch Hand

Joined: Jun 22, 2012
Posts: 754
Hi I want save in session values in my Servlet because, when I redirect to my page with

I the values are no displayed.

Could I set the values I get from processing my Servlet and display them direclty?

Any idea?

R. Jain
Ranch Hand

Joined: Aug 11, 2012
Posts: 375

Angus Ferguson wrote:
the values are no displayed.

Hello Angus,
Could you explain more clearly what values are you trying to display and where??
How you are passing it?? And how till now are you storing it in session (if so)..
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63867

The session is not necessary during a forward. Request scope is a better choice.

[Asking smart questions] [About Bear] [Books by Bear]
Pongsakorn Semsuwan
Ranch Hand

Joined: May 15, 2011
Posts: 34

This is how you set attribute to request and session. You have to set it before you forward your request to jsp.

Make sure that you understand the differences between session and request scope before choosing one.

And as R.Jain already mentioned, we need more information on what you are trying to do and how's your current situation.

A web application developer wannabe from Thailand
My StartUp :
Blog :
I agree. Here's the link:
subject: Save session inside a Servlet
It's not a secret anymore!