This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills: The software developer's life manual and have John Sonmez on-line!
See this thread for details.
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how can I pass a parameter to struts?

 
Monica Moncho
Ranch Hand
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Monica Moncho
Ranch Hand
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic