Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

a session problem  RSS feed

 
Rauhl Roy
Ranch Hand
Posts: 401
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey,

i have 3 jsp pages, first.jsp contians radio buttons second.jsp contains a dropdown list, a text box, third.jsp is used to show display summary of all slected values in first and second jsps.

and last two jsps have back buttons to modify first two.

what all scopes i should use here to run this application properly.

when i used to request scope for second jsp values without mentioning any thing for first application was working fine. but i need to show all values of first jsp in third.

can any one help me please.

regards,

rahul
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65830
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems that you already know that you'll need to employ the session.
 
Rauhl Roy
Ranch Hand
Posts: 401
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can please tell me if i can post i question here on the same topice with some difference...

if yes, please read the below mentioned ..

my first.jsp

<HTML>
<BODY>
<FORM METHOD=POST ACTION="SaveName.jsp">


What's your name? <INPUT TYPE=TEXT NAME=username SIZE=20>
<P><INPUT TYPE=SUBMIT>

</FORM>
</BODY>
</HTML>

this is my second jsp called savename.jsp

<%
String name = request.getParameter( "username" );
session.setAttribute( "theName", name );
%>
<HTML>
<BODY>
<FORM METHOD="LINK" ACTION="first.jsp">
<INPUT TYPE="submit" VALUE="Clickable Button">
</FORM>
<A HREF="NextPage.jsp">Continue</A>

</BODY>
</HTML>

this is my thirs jsp

<HTML>
<BODY>
<FORM METHOD="LINK" ACTION="SaveName.jsp">
<INPUT TYPE="submit" VALUE="Clickable Button">
</FORM>
Hello, <%= session.getAttribute( "theName" ) %>
</BODY>
</HTML>


even though i put my values in session, when i go back to first jsp using back buttons , the value entered there is not show. please help me.

regards,

rahul
 
Mani Venkata Kanth
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See When your using back button all values which are added to session will be available in first jsp also.
But your not getting the values from session and putting in your fields.

What you need to do is:
In first jsp check in session whether any attribute was set with the name 'yourname'. if it is not null it means that you used back button from 3rd jsp.
so then get the value from session and put it in input value attribute.

Got it!!!
I guess my answer will help you. Let me know for any clarification on this.

Regards,
Krishna Prasad
 
Rauhl Roy
Ranch Hand
Posts: 401
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what i was trying to tell you was, i want to put my data in like text box or drop down list or any kind of session scope. but when i come back ( from 3rd or 2nd jsp) should be able to edit it.

can you please send me code if you have any, i am also going to try and let you know if i manage the things. and can you please give me your maild id too.

See When your using back button all values which are added to session will be available in first jsp also.
But your not getting the values from session and putting in your fields.

What you need to do is:
In first jsp check in session whether any attribute was set with the name 'yourname'. if it is not null it means that you used back button from 3rd jsp.
so then get the value from session and put it in input value attribute.

Got it!!!
I guess my answer will help you. Let me know for any clarification on this.

Regards,
Krishna Prasad


[ June 06, 2007: Message edited by: Rauhl Roy ]
[ June 06, 2007: Message edited by: Rauhl Roy ]
 
Mani Venkata Kanth
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can reach me at : soft.munna@gmail.com
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rauhl,

Solution to your porblem can be:

FirstJSP.jsp


SecondJSP.jsp



ThirdJSP.jsp


Note: com.web.SaveRecord is a servlet that does the record saving
job. The code for that is not given here.


Thanks,
[ June 07, 2007: Message edited by: Chandra Bhatt ]
 
Rauhl Roy
Ranch Hand
Posts: 401
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thnk you very much mr bhatt for spending some time to give the answer to me and please give me your mail id to you to my frinends list and send me the programes used to save to the values.


regards,
rahul
 
Rauhl Roy
Ranch Hand
Posts: 401
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rauhl Roy:
thnk you very much mr bhatt for spending some time to give the answer to me and please give me your mail id to add you to my frinends list and send me the programe save record also please.
...

regards,
rahul
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rahul,

I have sent you the mail already; I got you mail-id you have provided to
JavaRanch.

I can be reached at [->chandra.m.bhatt@gmail.com<-]


Thanks,
[ June 08, 2007: Message edited by: Chandra Bhatt ]
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rahul,


I gave given you the code to just look how things could be done. A better
way to do that would be using Bean, and session listeners so that Bean could
be synchronized to the database row.

I have not yet coded that portion that saves the record to the dbase. Better
if you could tell me whether this sort of code is for production use.

Anyway, on behalf of this code I can try to code the save record part too.

Thanks,
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Separate class for database, record saving:



ThirdJSP.jsp



SaveRecordJSP.jsp




User Bean:
User.java



Thanks,
[ June 08, 2007: Message edited by: Chandra Bhatt ]
 
Rauhl Roy
Ranch Hand
Posts: 401
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is really great. thank you very much mr.bhutt... thnks you..

i will check my mail and will be in touch with you.

regards,
rahul
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!