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

pass parameter from jsp to jsp

Li Jenny
Ranch Hand

Joined: Apr 19, 2010
Posts: 57
i would like to ask you
if i have a home.jsp which contain 3 frame
header,and then bottom divide left menu and right content
i have resultset loop to diaply the data
<% while (rs.next()){ %>
<%=rs.getString(1);%>
<input type="hidden" value="<%=rs.getString("ID")%>" />
<% }>

how can i pass the parameter(rs.getString("ID")) to next.jsp when clicking the link.
in order i need the id to retrieve relvant data in next.jsp.
Amit Vinod Dali
Ranch Hand

Joined: Apr 14, 2010
Posts: 42

Web application development using JSP
Rajkumar balakrishnan
Ranch Hand

Joined: May 29, 2008
Posts: 445

@OP

give the hidden field an ID, and use in next JSP page. Thats it.
Li Jenny
Ranch Hand

Joined: Apr 19, 2010
Posts: 57
return value is NULL when i give the hidden field a name
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Hidden input field values will only be passed if a form is submitted.
Forms are not submitted when hyperlinks are pressed.
If you want to pass parameters when a hyperlink is passed, you'll need to add them to the URL as querystring parameters.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Li Jenny
Ranch Hand

Joined: Apr 19, 2010
Posts: 57
if i use query, when the page is redirected from this link is nornally worked.
but when i call the nex.jsp not by the query.
then nullpointexception error occurs.
at <%request.getParameter("id")%>

how can i fix?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42610
    
  65
What do you mean by "call the nex.jsp" - how, exactly, does that work?


Ping & DNS - my free Android networking tools app
Li Jenny
Ranch Hand

Joined: Apr 19, 2010
Posts: 57
sorry,let me explain more.
in home.jsp i have a link
<%=rs.getString("ID")%>" target="_self"><%=rs.getString("ID")%>


in next.jsp:
<% String id= request.getParameter("id")%>

it is ok when next.jsp is sent from home.jsp
but when the next.jsp is call from other page,does not apply query string 'id'
there is nullpointexception occurs as 'request.getParameter('id') does not extist.

how to prevent?? i try to code as belows,but it seens has error occurs:

if( request.getParameter("id").equals(null)){

request.getParameter("id").equals("");
}

to prevent null. but still has problem.

how to fix?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42610
    
  65
Something like

if (request.getParameter("id") != null) {
...
}
Li Jenny
Ranch Hand

Joined: Apr 19, 2010
Posts: 57
how can i use javascript to pass parameter from popup window to opener window because i need to submit the opener window and close the popup from js.

so that opener window to get value by:

<%request.getParameter('id')%>
Harpreet Singh janda
Ranch Hand

Joined: Jan 14, 2010
Posts: 317

Instead of setting/getting it as a parameter. Set it as an attribute (request.setAttribute()). This will be more convenient.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: pass parameter from jsp to jsp