This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes how can I pass a parameter to struts? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "how can I pass a parameter to struts?" Watch "how can I pass a parameter to struts?" New topic
Author

how can I pass a parameter to struts?

Monica Moncho
Ranch Hand

Joined: Dec 01, 2004
Posts: 31
hi,

I am changing a small app that I have to use struts, but I don't know how to convert this:

In one page I am retrieving a list from a table and I am adding links with an index from the table, so the links are something like this:

<a href="www.updatethis.do?index=1">...
<a href="www.updatethis.do?index=2">...
<a href="www.updatethis.do?index=3">...

so when you click on the link the index will be passed to the servlet.

I tried changing from my web.xml to the struts config file but I get a null
pointer error. It seems it is not finding my path in struts because of the parameter?

I am just starting with struts so I am confused.

Thanks for your help.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
A Struts Action path should not contain a dot (.). Get rid of the "www." and just specify path="/updatethis" in your action mapping. Then the link:

should work just fine, provided the current page was served from the web context root.

If you want to avoid context issues, you can use the following:

The above will work regardless of the context of the enclosing JSP.


Merrill
Consultant, Sima Solutions
Monica Moncho
Ranch Hand

Joined: Dec 01, 2004
Posts: 31
mmm, I thought I did it that way (the first one).

I'll try the second way you say and if I still get the error maybe it is somewhere else.

thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how can I pass a parameter to struts?
 
Similar Threads
How can this be done better (html:link)
how to call a specific action
Javascript and Struts Indexed Text Boxes
Struts +retrieving values from text area
Question on Links using struts