- This topic has 9 replies, 3 voices, and was last updated 19 years, 9 months ago by flamesnm.
-
AuthorPosts
-
ajsMemberIs there a simple and straightforward way with Struts to pass a single dynamically generated parameter from one JSP page to another JSP page?
As an example –
We have a jsp page listing customer orders and we want to link from a single order in the list to a page showing just that one order with all the details. The link would pass a variable order number.Conceptually the link should be the equivalent of
/singleOrder.jsp?orderNum=18472
(which of course doesn’t work).
And the link could be created with something like<html:link forward="toSingleOrder" paramId="orderNum" value="<%=orderNumber[x]%>">order details</html:link>
Finally the retrieval of the order number in singleOrder.jsp could be something like
String orderNo = request.getParameter("orderNum").toString();
All the info found on this matter via google has seemed to be convoluted or obscure and lacks specific examples. Any help on this would be much appreciated.
– System Setup ——————————-
Operating System: Win 2K
Eclipse version: 3.0.1
Eclipse build id: 3.8.3
Fresh Eclipse install
No other installed external plugins
Riyad KallaMemberMoving to OT > Soft dev, this isn’t MyEclipse related.
Riyad KallaMember/singleOrder.jsp?orderNum=18472
Why doesn’t this work? Is there another request/response cycle between the two JSPs that looses the query string?
ajsMemberThanks for the response.
There should be nothing between the two jsps – unless Struts is adding something.
I thought
/singleOrder.jsp?orderNum=18472
should work, but in singleOrder.jsp there seemed no way to find orderNum, so I am assuming it can’t be passed this way.
I am open to trying anything that might make this direct approach work.
Riyad KallaMembershould work, but in singleOrder.jsp there seemed no way to find orderNum, so I am assuming it can’t be passed this way.
This *is* fine to do, it a standard query string parameter. You should be able to use the request.getParameter(String), request.getParameters(String), request.getParameterMap, etc. methods to retrieve this value.
If you were trying to use the getAttribute methods, then that is likely why you weren’t getting anything returned. The ‘attribute’ fields are hashstables that can be used to set/get values that are passed from the application level back and forth… the ‘parameter’ values are from POST/GET operations to your pages from the client.
ajsMemberIn singleOrder.jsp I used
String orderNum = request.getParameter("orderNum").toString();
but this generates a NullPointerException in the _jsp.java
Riyad KallaMemberHere is a sample project that submits a value from a link and a form to a page that prints the value out. Compare it to yours and see what might be going wrong (make sure you didn’t map the struts servlet to *.jsp or something like that)
Attachments:
You must be logged in to view attached files.
ajsMemberDid you miss adding a link or an attachement to your answer?
Thanks.
Alan
ajsMemberNow I see it.
Thanks.
flamesnmMemberHi
Could I piggyback on this thread as I’m having the same problem. It should be simple 😳
I’m linking from a static HTML page to a .jsp with :
<INPUT type=”button” value=”start”
onclick=”window.open (‘http://172.19.15.167:9080/MailDatabase/mailin.jsp?appName=colour‘, ‘newwindow’, config=’height=400,width=314, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, directories=no, status=no’)”></form>However, I get a null value from the request with :
String appCode = request.getParameter(“appName”);
contact.setAppCode(appCode);When I view the request through debug all the parameter in the action form are present in the request, but the appName parameter doesn’t appear.
Regards
-
AuthorPosts