aspose file tools*
The moose likes Struts and the fly likes Form action Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Form action" Watch "Form action" New topic
Author

Form action

hari gutta
Ranch Hand

Joined: Mar 03, 2013
Posts: 33

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

Joined: Oct 29, 2001
Posts: 8911
    
    8

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?


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
hari gutta
Ranch Hand

Joined: Mar 03, 2013
Posts: 33

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

Joined: Nov 17, 2012
Posts: 45
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Form action