cancel
Showing results for 
Search instead for 
Did you mean: 

Struts Dummy question

Steven_UM
Contributor
0 Kudos

Hi folks,

I am diving into the wondefull world of struts - I found a very simple tutorial at http://wiki.apache.org/struts/StrutsMinimalInstall but I am getting a runtime error which I don't grasp when executing it on SAP WebAS 6.40 ...

If the web.xml would contain

<servlet-mapping>

<servlet-name>ActionServlet</servlet-name>

<url-pattern>/*.do</url-pattern>

</servlet-mapping>

and my welcome.htlm file has a form with action="name.do"

then I would assume that this request goes through the ActionServlet which basically does

return uActionMapping.findForward("success")

using in the struts configuration file

<action

path="/name"

type="com.sedacrivity.struts.test.actions.NameAction"

input="/Welcome.jsp"

name="nameBean"

scope="request">

<forward name="success" path="/hello.jsp"/>

<forward name="failure" path="/error.jsp"/>

</action>

then why am I getting the following ?

http://localhost:50000/GMData/name.do?name=steven

"Requested resource does not exist ...." doh !

Am I missing something basic here ?

My archives compile allright and get deployed without any issue ...

Thanks,

Steven

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Steven

I think it is because your servlet mapping is incorrect.

Try changing it from

<url-pattern>/*.do</url-pattern>

to

<url-pattern>*.do</url-pattern>

.

Hope this helps,

Gareth.

Steven_UM
Contributor
0 Kudos

Hi Gareth,

That did the trick !

But I don't grasp the difference ... if I address a file in the root dir then putting the "/" or not should not make a difference or does it ?

Regards,

Steven

Former Member
0 Kudos

Hi Steven,

I'm not a struts expert unfortunately, I've just been using the technology as part of a CRM ISA B2B & B2C implementation I've been working on...

But, my understanding is that the url pattern is simply a way to force any links in a page to be handled by the struts action controller. The ".do" is just a way of saying any links that end with .do should be parsed by the struts action servlet thing and then handled accordingly. I guess that you could change this to ".mickeyMouse" and as long as your links were updated they would still run through the struts processing. Think of it as an entry point into the config.xml file. You aren't actually setting up folders or anything so the slashes become irrelevant.

Hope this makes some sense!

Cheers,

Gareth.

Answers (1)

Answers (1)

Former Member
0 Kudos

I'm not sure, but

In your <action> tag, you say input="/Welcome.jsp".

Shouldn't this be welcome.html. Because that is the page you are coming from ?

regards,

Peter

Steven_UM
Contributor
0 Kudos

Hi Peter,

Thanks for your suggestion ...

You were correct that this could not work but I typed in the wrong example sorry ... I am using Welcome.jsp all along ....

But still thx for looking into it ...

Regards,

Steven