Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem sendRedirect to JSP page

 
Thamu Gurung
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am having problems in sendind Re-direct to JSP page .

I am able to get the datas displayed in the servlet ,, bu no idea of redirecting it to JSP page ...fresher in JSP and Servlets

My codings for sevlet is as follows:-



now I want o get all these seven fields to be displayed in a jsp file (users.jsp),, please give me some guidelines to do this .
How to pass the above values in the jsp file.


as my users.jsp file is having errors ..
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64824
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A few points:
  • You are doing a forward, not a redirect. They are not the same. In this case, a forward is correct.
  • The logic in your servlet is such that the values are being over-written on each loop. At the end of the loop all you have is the data from the last iteration. Ths is certainly not your intention.
  • To make the data available to a forwarded JSP, you create scoped variables in the request. You do this with request.setAttribute().
  • In your JSP, be sure to avoid old-fashioned scriptlets and use modern mechanisms such as the JSTL and EL.
  •  
    Thamu Gurung
    Ranch Hand
    Posts: 39
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    hi,

    Thankyou . I will try this and let you know.

    Regards
     
    Thamu Gurung
    Ranch Hand
    Posts: 39
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    hi,

    my error is like this now :-




    I could not figure out , how i have used the duplicationn of the local variable user

    :- User is a class file which having getter methods returning the values; and " users" is the attribute which was setted.

    Regards




     
    Bear Bibeault
    Author and ninkuma
    Marshal
    Pie
    Posts: 64824
    86
    IntelliJ IDE Java jQuery Mac Mac OS X
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    So I see that you ignored my advice not to use scriptlets.
     
    Ilya Cyclone
    Greenhorn
    Posts: 4
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Thamu,

    in yout JSP there should be smth like:

     
    Thamu Gurung
    Ranch Hand
    Posts: 39
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Ilya and Bear ,
    Sorry for using the scriplets , and thankyou for your logic

    And thankyou Ilya for giving me that hint.

    Now its done .

    Regards ,


     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic