Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Forwarding an attribute from 1 jsp to another?  RSS feed

 
Ravi Sathish
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Here's my requirement:
In my database I have username, password and FullName.
I have a Login page ("Login.jsp"); where I get parameters, username, password.. I post these parameters to a Servlet (Login.java) which queries the database to find if the username exists.
Now on successful login.. I need to forward the FullName;
For request parameter; I am setting the attribute("fullname",rs.getString(fullname));
Using RequestDispatcher I am dispatching it to WelcomeWiz.jsp; Here I have a frame whre the full name needs to be displayed.
Is there a way I can forward an attributed from an Jsp to a HTML page?
Or should I use 1 more JSP for this? How to forward attributes from 1 jsp to another?
TIA
RAVI

Now
 
Praful Thakare
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I understood your question correctly then it is in following way
You have one servlet called Login.java which have following lines

1 request.setAttribute("fullname",rs.getString(fullname));
2 RequestDispatcher rd=request.getRequestDispatcher("WelcomeWiz.jsp");
rd.forward(request,response);
And your WelcomeWiz.jsp has some thing like this


and you want to pass fullname from WelcomeWiz to either t1 or t2.html
now comes your question
Is there a way I can forward an attributed from an Jsp to a HTML page?
There is no such way (as per my knowledg,plz update it if there is ).
You need to call jsp instead of your html (t1 or t2)as follows

And TEMP.jsp will have
<%=request.getParmeter("fullname")
%>
OR
you can also put full name in session in Login.java
and access it directly in Welcome.jsp
cheers
Praful
[ November 06, 2003: Message edited by: Praful Thakare ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!