A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
Arduino in Action
this week in the
General Computing
forum!
A special promo:
Enter your blog post or vote on a blogger to be featured in an upcoming Journal
JavaRanch
»
Java Forums
»
Java
»
Servlets
Author
Save session inside a Servlet
Angus Ferguson
Ranch Hand
Joined: Jun 22, 2012
Posts: 281
posted
Sep 18, 2012 05:43:43
0
Hi I want save in session values in my
Servlet
because, when I redirect to my page with
RequestDispatcher dispatcher = request .getRequestDispatcher("/index.jsp"); dispatcher.forward(request, response);
I the values are no displayed.
Could I set the values I get from processing my Servlet and display them direclty?
Any idea?
Thanks
R. Jain
Ranch Hand
Joined: Aug 11, 2012
Posts: 276
I like...
posted
Sep 18, 2012 05:59:05
0
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)..
OCPJP
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56549
14
I like...
posted
Sep 18, 2012 08:31:25
0
The session is not necessary during a forward. Request scope is a better choice.
[
Smart Questions
] [
JSP FAQ
] [
Books by Bear
] [
Bear's FrontMan
] [
About Bear
]
Pongsakorn Semsuwan
Ranch Hand
Joined: May 15, 2011
Posts: 34
I like...
posted
Sep 28, 2012 04:07:18
0
This is how you set attribute to request and session. You have to set it before you forward your request to jsp.
request.setAttribute("name", value); session.setAttribute("name", value);
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 :
http://www.dreamlog.co
Blog :
http://pongsakornsemsuwan.wordpress.com
I agree. Here's the link:
http://zeroturnaround.com/jrebel
- it saves me about five hours per week
subject: Save session inside a Servlet
Similar Threads
how to use uploaded file
Problems with servlet filter
accessing session variables when we use sendRedirect
session in netscape 4.7
My servlet Notes
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter