• Post Reply Bookmark Topic Watch Topic
  • New Topic

unable to pass the dynamic value to servlet from jsp

 
ram pandey
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am able to fetch the dynamic value from database to show it in a jsp page.

but facing some conceptual problem herefrom, now I want show this dynamic value in the next Servlet page and I have done first to set the value(in jsp page):

and trying to get the value from the servlet page (in servlet page code) :

Still I am unable to fetch the dynamic value in servlet.
Any suggestion on this regards will be appriciated.
 
mallikarjun dontamsetti
Ranch Hand
Posts: 246
Firefox Browser Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First don't call resultset(rs) in JSP. Why do you need to again call resultset in servlet jsut get the empid into string(parse it if required) set it to session.
 
ram pandey
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mallikarjun dontamsetti wrote:First don't call resultset(rs) in JSP. Why do you need to again call resultset in servlet jsut get the empid into string(parse it if required) set it to session.

I am using resultset to fetch the dynamic values to show in the jsp page,but I'm not using the resultset in the servlet,still my //String emp = (String) session.getAttribute("empId");// value showing the null value.
Any suggestion....... ?
 
Palak Mathur
Ranch Hand
Posts: 342
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where is the following line in your code located:-




Try to show us some more code to help us understand what exactly you are doing.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch ram pandey !

and now coming to your question,

1. you are not able to get.!. it will not help us to understand your problem. you need to be more specific. what error you are getting?

2. you should not use scriptlet in your jsp(maintenance will be nightmare). and top of that getting a connection in jsp is sin.(I would like to bring one of the draw back:every time you refresh new connection object created and destroyed)

3. Ok, now why you are not getting the session value on servlet?
becasue you are setting nothing in to session. you set call should go inside the while. and importantly you need to submit the form to servlet or call the servlet.

Note: you should not call a jsp directly. request a servlet ---> do business logic and fetch values --> forward/redirect to jsp-->show up tthe values to a user.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!