File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes URL rewriting and Struts  how-to Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "URL rewriting and Struts  how-to" Watch "URL rewriting and Struts  how-to" New topic

URL rewriting and Struts how-to

Sanjay Deshpande
Ranch Hand

Joined: May 22, 2001
Posts: 111
i want to pass a parameter to my foreward page like this
<a href="mypage.jsp?valid=1"/>
how do i do that using struts?
in struts-config.xml, how do i specify a parameter like that?
Michal Bienek

Joined: Jun 17, 2002
Posts: 29
There are many ways to send this kind of data over to your forwarded page. Your safest bet is to create an Action and add your data string to the request as an attribute, and then fetch it from your forwarded page. I say this is the safest since it uses the framework the way it's meant to be used.
There is no way to specify dynamic parameters like that in the struts-config.xml. If you did have an Action leading to your forwarded page, and you absolutely wanted this data to be a "parameter", you could get the forward mapping (i.e. mapping.getForward("success") and then create a new forward based on the returned ActionForward, from which you could append your data to the path, but again, you'd be forced to ensure that the format of your data conforms to a query string.
I'd recommend placing it as a request attribute.
Sanjay Deshpande
Ranch Hand

Joined: May 22, 2001
Posts: 111
I am new to struts and do not know exactly how this can b implemented.
Can u plz write 2 lines of example code or illustrate more .
I agree. Here's the link:
subject: URL rewriting and Struts how-to
It's not a secret anymore!