You need to use wildcard action mappings:

http://struts.apache.org/userGuide/building_controller.html#action_mapping_wildcards

I've posted around this subject a few times; check the archives for threads with 'path info' or 'wildcard' in the subject :-)

L.

Ed Griebel wrote:

Hmm, that's interesting, with one of my webapps it doesn't work for me either!
I haven't had a use for this yet so I haven't run into this issue, so
I don't know if there's a standard way to handle this in Struts. Seems
like extending RequestProcessor to ignore trailing url arguments is
over the top!

-ed

On 7/21/05, Daniel Łaś <[EMAIL PROTECTED]> wrote:

Hi Ed

Thanks for your help.

Ed Griebel napisał(a):


Hi Daniel-

1) You can set up a Session Listener, which is a class which
implements HttpSessionListener. You implement 2 methods,
sessionCreated() and sessionDestoryed() to do what you need to. This
will need to be added to web.xml file under a
<listener><listener-class>class path and
name</listener-class></listener>. Here is an old article but it's
still valid, and discusses the different kind of servlet events you
can trap: http://www.onjava.com/pub/a/onjava/2001/04/12/listeners.html?page=1

2) You need an entry in your struts-config.xml file which associates
your action class with an action path. It sounds like you might not
have set this up. It would look something like this, inside of an
action-mappings entry. There's other entries that need to be in your
struts config too.
<action path="/DefaultAction"
  type="[class path].DefaultAction"
  name="[your form bean name]">
  <forward name="success" path="default_success.jsp"/>
  <forward name="failure" path="error_page.jsp"/>
</action>

In web.xml, declare the request procesor and add a servlet mapping
that will send all files ending with *.do to the struts request
processor:
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
  <param-name>config</param-name>
  <param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping><servlet-name>action</servlet-name><url-pattern>*.do</url-pattern></servlet-mapping>



DefaultAction.do works well for me, only DefaultAction.do/aa/bb doesn't.


It's a lot of stuff to do in web.xml, but at least you only need to
set it up once.

Here's a great intro to struts, should help you get up and running:
http://www.reumann.net/struts/main.do

Good Luck!
-ed

On 7/21/05, Daniel Łaś <[EMAIL PROTECTED]> wrote:



Hi

I'm new to Struts and have two questions:
1. How can I define common session initialization routines, eg. I'd like
to run some code every time session is created.
2. How should I configure struts/tomcat to make PathInfo avalbale? Lets
say I have DefaultAction action configured. When I type
URL: /DefaultAction.do/a/b/c I recive error page _ _saying that
resourceis not available

Regards and thanks in advance



Regards

--
Daniel Łaś <[EMAIL PROTECTED]>

e-direct Polska sp. z o.o.
ul. 1-go Maja 9
45-068 Opole
tel. +48 77 44 17 868


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--
Laurie, Open Source advocate, Java geek and novice blogger:
http://www.holoweb.net/laurie


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to