aspose file tools*
The moose likes JSP and the fly likes Session Textbox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Session Textbox" Watch "Session Textbox" New topic
Author

Session Textbox

Rakesh Keerthi
Ranch Hand

Joined: Jul 16, 2012
Posts: 144
Hi,
i want to make a textbox to a session one as i want to use it in all my web app. here there are 2 textboxs named Allocation and tgt1. once i click a button the value in first textbox gets copied to the second textbox(which is going fine) and i want to use this textbox in session as the next page is taking its reference to update the database. the code that i tried so far is as below.

the jsp used to move the values is



the textboxes are



the code to retrieve data used in another jsp to display data is

<input type="text" name="Comp_Text" id="Comp_Text" value="<%=session.getAttribute("abc")%>"/>//this is displaying null


and in servlet i used:

String ab=(String)session.getAttribute("abc");


please help me to reslove it.

Thanks


Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

at the time of setting value into session, print the value. i.e,



It's common illusion to a developer to think scriptlet executes after the html code processing.
Rakesh Keerthi
Ranch Hand

Joined: Jul 16, 2012
Posts: 144
Hi Seetharaman,

It is showing null when i do it. i'm using javascript(which i think is a client side one) so i need to do it in the server side if i'm assigning a session to allocation textbox directly it is working fine(session.setAttribute("abc", request.getParameter("Allocation"));), but, i'm unable to know how to do it for the text in tgt1(second text box) as it is copied using a javascript.

Thanks
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Ok, you copy the value from one textbox to another via javascript. now you are submitting this form to another which contains below fragment


before this are you calling any servlet(or any intermediate component), if yes set there else(directly submitting to another jsp) ,
then the value will be in request param, you have to use as in


[or]



by the way: If possible, please avoid scriptlet .
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575



here expression has " it may conflict with value attributes " . so use like below:


<edit>
here it wont be a problem, since scriptlet executes far before html. but you may have problem when you start using tags....
</edit>
Rakesh Keerthi
Ranch Hand

Joined: Jul 16, 2012
Posts: 144
it is still pulling null
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Session Textbox