Hi,
I have a jsp page (page1.jsp)which is in form of a table with 4 data items.Each of these is a separate function.,user,site,txn,target.
1)
user id........textbox
user name..textbox

find user..button

when i click on find user it navigates to Displayuser.jsp from where i select the values and pass back to page1.jsp(using submit button and action="page1.jsp)....this much is workin all right.

Now i do the same for site ..but when i get site id and name back form Displaysite.jsp to page1.jsp ,the fields user id and user name become empty!!!..and so on for txn and target..

How can i retain the user fields once selected even when it goes to Displaysite ,Displaytarget, Displaytxn etc and comes back???..

I have to save all the fields in a db table so need all of them to be present and not null!..Please help..thx

There are different ways of persisting data across multiple requests; session object being one of them. You can save the create a bean class for all logically related data and store its instance in the HttpSession.

Another way would be to use hidden form fields to pass values to and fro and maintain them across requests. The disadvantage here is that each time you land on a page, you need to create hidden form fields which would hold the data that needs to be passed to your target page.

Hi,Thx sos for ur help..i understand the idea bt m not able to implement in properly..
these are the files m using.
user.jsp-----

String upid = 	(String)enum.nextElement();
  	String upname = (String)enum.nextElement();

	UpBean myupbean=new UpBean();

	myupbean.setUid(upid);
	myupbean.setUname(upname);
	session.setAttribute("MyBean",myupbean);

site.jsp----

String supid =(String)enum.nextElement();
  String supname = (String)enum.nextElement();
UpBean myupbean=(UpBean)session.getAttribute("MyBean");
myupbean.setSid(supid);
myupbean.setSname(supname);
session.setAttribute("MyBean",myupbean);

AddProfile.jsp-----

String id1 = request.getParameter("idradio");
    	String name1= request.getParameter("namerad");
	
	
	if(id1 == null && name1 == null){
			UpBean myupbean=(UpBean)session.getAttribute("MyBean");
			id1=myupbean.getUid();
			name1=myupbean.getUname();
	}


.
.
.
.
String sid1 = request.getParameter("sidradio");
    	String sdesc1= request.getParameter("sdescrad");

if(sid1 ==null && sdesc1 == null){
			UpBean myupbean=(UpBean)session.getAttribute("MyBean");
			sid1=myupbean.getSid();
			sdesc1=myupbean.getSname();
	}

AddProfile is where the values are displayed.The fields are null when the page is first opened.

I m getting null pointer exception in the above code..

How should i use session correctly?..
have defined a class UpBean.java with get() set() methods..

Please help..thx

The code posted seems good enough though I am pretty much confused as to how these parts fit in the entire application or the page itself.

Values set in the session are not persisted across requests only when there is some problem with session creation. Make sure your localhost or your dev server is in trusted zone and cookies are enabled. Playing around a bit with the session object; i.e. setting some variable in session scope and retrieving it on the next page should give you a good idea on where exactly the problem lies.

Hi im getting increasingly frustrated with it now!!!..its not showin null pointer exception now but shows in textboxes only the last values in each table.

I need to know how can i put the selected radio button value and its associated field(id and name resp in my case) in the session variable?..so that it saves that i can retrieve it w/out anymore headaches..thx for ur help..

<%@ page import="loginpack.UpBean" %>
<jsp:useBean id="myupbean" scope="session" class="loginpack.UpBean" />


String upid = (String)enum.nextElement();
 String upname = (String)enum.nextElement();
	
//myupbean=(UpBean)session.getAttribute("MyBean");(if i use this i get null ptr exception!!!)
myupbean.setUid(upid);
 myupbean.setUname(upname);
session.setAttribute("MyBean",myupbean);
%>
	
<tr><td>
<input type="radio" name="idradio" selected="false"  value="<%= upid %>" 
onClick='javascript:userform.namerad.value=
"<%= upname %>" '   />
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.