Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

modify extension .do to .web

 
Brian Grey
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 624
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 624
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my mistake... it did a bad copy-paste
everything is perfect now

thanks for your help
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic