Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Form action

 
hari gutta
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Greetings,

From this tutorial, I came to know that we can have something like this in JSP page

<form action="hello">
<label for="name">Please enter your name</label><br/>
<input type="text" name="name"/>
<input type="submit" value="Say Hello"/>
</form>

But if I try to execute the code in the similar way, it navigates to the page
http://10.210.43.136:7001/Struts/hello?name=SECRET

Which didn't make sense to me..I thought the uri should be
http://10.210.43.136:7001/Struts/hello.action?name=SECRET

So I changed the code to
<form action="hello.action">
<label for="name">Please enter your name</label><br/>
<input type="text" name="name"/>
<input type="submit" value="Say Hello"/>
</form>

Which gave me a better error, "There is no Action mapped for namespace / and action name hello." I am sure I need to add some attribute namespace in struts.xml and finally I can comeover this error(cause, I got the same error in the past, and I finally did some modifications to make the program execute)

Now my question is
1. Is this legal??
<form action="hello">

If so why is my program not executing in this way?? Is it some versions problem??
 
Joe Ess
Bartender
Posts: 9320
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Niharika Gottipati wrote:
Now my question is
1. Is this legal??
<form action="hello">


It looks like the tutorial doesn't use the Struts tag library, so yes, the form tag should look like

If he did use the Struts tag library, the tag would be (plus you'd have to declare the tag library at the top of the JSP file):

It looks like the tutorial author got confused.

You do not need to declare a namespace. There is a default namespace which is "/".
What does your struts.xml file look like?
 
hari gutta
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The tutorial added the tag at the top, but didn't use
<s: form>..

Looks like it's some silly point I am missing..

I am unable to run with form tag, I developed a simple app that just displays some data and it is working fine.

So looks like the prob is with form, might be passing parameter to setX() or whatever.

Here is my struts.xml :
 
Ayan mallick
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no Action mapped for namespace / and action name hello.


if this is the error then check whether you have placed struts.xml in classpath or not if in eclipse check whether you put it in src folder or not.
check log after server start up whether it is being loaded or not.

use struts 2 tag lib and check the page view source whether action has been appended by tag lib during translation.

struts.xml looks fine.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic