Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

problem sendRedirect to JSP page

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ..
 
Sheriff
Posts: 67634
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
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
      Number of slices to send:
      Optional 'thank-you' note:
    • 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
      Number of slices to send:
      Optional 'thank-you' note:
    • 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
    Sheriff
    Posts: 67634
    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
    So I see that you ignored my advice not to use scriptlets.
     
    Greenhorn
    Posts: 5
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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
      Number of slices to send:
      Optional 'thank-you' note:
    • 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 ,


     
    See where your hand is? Not there. It's next to this tiny ad:
    free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
    https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
    reply
      Bookmark Topic Watch Topic
    • New Topic