wood burning stoves 2.0*
The moose likes Struts and the fly likes modify extension .do to .web Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "modify extension .do to .web" Watch "modify extension .do to .web" New topic
Author

modify extension .do to .web

Brian Grey
Ranch Hand

Joined: Nov 15, 2002
Posts: 43
Is there a way to specify the extension of a struts action?

Example:
http://127.0.0.1:8080/Card/Provisioning/Create.do

I'd like to change it to

http://127.0.0.1:8080/Card/Provisioning/Create.web


I want to do this because I need to get rid of the security constraint for this action (only this one). This action must be accessible for everyone without going trough the login page (the user should not get the login page if he clicks on this link)

So, I was thinking to solve my problem by adding another security-constraint section into web.xml.

I'm not sure if this could work. Is there a way to tell struts that the action /Card/Provisioning/Create should be /Card/Provisioning/Create.web instead of Create.do ?

Thanks


struts-config.xml:

<action input="/Card/Provisioning/CreationInput.jsp" name="cardForm" path="/Card/Provisioning/Create" scope="request" type="com.gemplus.preview.gui.card.ProvisioningCreateAction" validate="true">
<forward name="forward" path="/Card/Provisioning/CreationResponse.jsp"/>
</action>


web.xml:

<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>


<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.web</url-pattern>
</servlet-mapping>


<security-constraint>
<web-resource-collection>
<web-resource-name>With auth-constraint</web-resource-name>
<url-pattern>*.do</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>serviceManager</role-name>
<role-name>csr</role-name>
</auth-constraint>
</security-constraint>


<security-constraint>
<web-resource-collection>
<web-resource-name>Without auth-constraint</web-resource-name>
<url-pattern>*.web</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
</security-constraint>
Mark Vedder
Ranch Hand

Joined: Dec 17, 2003
Posts: 624

In your deployment descriptor (i.e. your web.xml) you set the desired url-pattern in the servlet-mapping for the ActionServlet:

Mark Vedder
Ranch Hand

Joined: Dec 17, 2003
Posts: 624

I just noticed in the web.xml you posted, you have two <servlet-mapping>'s for the "action" Servlet, each defining different <url-patterns> - *.do and *.page. I suspect that is your issue (having multiple servlet-mappings for the same servlet).

Also, I do not see a <servlet> declaration for the "action" servlet; I'm not sure if you simply didn't post that, or if it is missing. One is needed. It's name (i.e. <servlet-name>) must match the value of the <servlet-mapping>.
[ January 20, 2005: Message edited by: Mark Vedder ]
Brian Grey
Ranch Hand

Joined: Nov 15, 2002
Posts: 43
my mistake... it did a bad copy-paste
everything is perfect now

thanks for your help
 
 
subject: modify extension .do to .web
 
Similar Threads
weblogic 9- authentication
security constraint question
security-constraint in web.xml
Security Problem
Security