File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes How to get  parameters from servlet into jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "How to get  parameters from servlet into jsp" Watch "How to get  parameters from servlet into jsp" New topic
Author

How to get parameters from servlet into jsp

shiju nair
Ranch Hand

Joined: Jul 18, 2008
Posts: 45
I am working on a project wherein I have to perform the Attendance apply and approve scenario.I have made a jsp page which has textbox username and password.After that i have created a servlet where the database connectivity is done as well as the validation.Now i am making another jsp for the welcome page to the particular user, based on the username and password provided .My first jsp page is test.jsp,the servlet class is Helloserv.class and the third jsp is login.jsp.In the servlet i have used .But what code is needed in the jsp which will accept parameters through which a new page is seen as well as only the particular user details is seen throughout the session.
thanks in advance.Help will be highly appreciated.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Originally posted by shiju nair:
what code is needed in the jsp which will accept parameters through which a new page is seen as well as only the particular user details is seen throughout the session.


Well, you place the user details into the session in servlet using setAttribute("key","value")..(Before the RequestDispatcher)

then get the session value and display in liogin.jsp using getAttribute("key")
shiju nair
Ranch Hand

Joined: Jul 18, 2008
Posts: 45
Thanks for the answer,i needed.
I have a query on the same thing that is,once the setAttribute is placed in the servlet then through this the values are retrieved in jsp right.But should i make a bean or a normal jsp where in bean i have to specify the servlet class but i should be using the or the for the .so that the user goes ahead with a new page and does other activities for example leave apply. Which of course will need the database connectivity to update the database.so i should use the same servlet class or again i have to make a new one.
please suggest.help highly appreciated.
Thanks in advance.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Hi,

1.useBean is discourage nowadays
---------------------------------
use JSTL=customtags+EL
---------------------------------

2. you want to take userdetails entire web application right?....
then use session or application,why you want to use useBean
shiju nair
Ranch Hand

Joined: Jul 18, 2008
Posts: 45
Thanks for the suggestion.
But i am not familiar with and because of that i wont be able to do proper coding .An example of that coding would be preferred.so I hope you would help me with it.
Thanks in advance.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Originally posted by shiju nair:

But i am not familiar with and because of that i wont be able to do proper coding .An example of that coding would be preferred.so I hope you would help me with it.


I hope HFSJ help you ;) ... please read the HFSJ
shiju nair
Ranch Hand

Joined: Jul 18, 2008
Posts: 45
Thanks for the suggestion
but i am not able to view a clear picture of jstl
because hfsj is not available.We need to purchase it online.Isn't there any other way out as i said using bean to go ahead with the scenario.
Thanks in advance.Help will be appreciated.
 
jQuery in Action, 2nd edition
 
subject: How to get parameters from servlet into jsp
 
Similar Threads
Doubt on calling java class in Servlet
validation problem using jsp,servlets,ms-access db
How to display Ajax result on the same jsp page
Session Tracking
Infinate loop between JSP and Servlet - getParameter scope appears to be indefinate