• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

unable to retrive servlet data in jsp page

 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i tried to retrive a value passed by the request dispatcher method in "login servlet " but unable to get it in "login.jsp"


login servlet:



login.jsp


does requestdispatcher pass the variables in login servlet.if it passes then why i am not getting the value or does
it require to pass value explicitely..
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

tushar panda wrote:a value passed by the request dispatcher method in "login servlet "


Where? There is nothing in your servlet code to pass the value to the JSP.

Use the following:


Then in the JSP:


 
tushar panda
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in line 2 in login servlet i have mentioned in comment that the address1 is the target page(which i have set before as login.jsp) and in
line 1 i am getting the desired value of "msg" variable . which means when line 3 is executed requestdispatcher must pass it to login.jsp . and in login.jsp in line 3 i must get the value because i retrieved it in line 2 .
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have no idea what you are trying to say.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You've retrieved the value (a parameter) but never set it as an attribute--so it won't be available on the JSP. Did you try what Bear suggested?
 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try this




then

 
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are a few things missing from your servlet code which makes it difficult to predict what's going wrong.



How did you retrieve msg?? Is it retrieved as request.getParameter("msg")?? Secondly, what's the value of address1?? Have you overwritten the msg request parameter like Request parameters are passed as is when you use request dispatcher (unless you override them as the example that I gave).

Led did you try your program?? You are setting a request attribute and extracting a request parameter in the JSP. That will not work. Using scriptlets in JSP is also not a very good idea. The solution that Bear gave is the easiest way of achieving the result...
 
reply
    Bookmark Topic Watch Topic
  • New Topic