This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Struts and the fly likes How to customize mapping in struts-config.xml ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to customize mapping in struts-config.xml ?" Watch "How to customize mapping in struts-config.xml ?" New topic
Author

How to customize mapping in struts-config.xml ?

Krish baskar
Greenhorn

Joined: Dec 23, 2007
Posts: 10
Hi
I have a code to test that submits file to upload to a CGI url. I have a struts application to replace CGI server that takes uploaded file. All I need is, I would like to repalce the CGI url in place of .do
Current struts URL is https://hostname/jack/FileUploadAndSave.do
struts-config.xml contains

web.xml contains

I would like to use in my jsp page as

Could someone help me out please ?
James Ward
Ranch Hand

Joined: Apr 27, 2003
Posts: 263
If i have understood correctly - you want to use a CGI to handle your uploads, and struts action should not handle your upload.

If this is the case, you are already set, and do not need to do anything in struts-config.xml OR web.xml. Remember as per your entry in web.xml, struts will come into play ONLY if the URL has a .do in it.

So, if your upload is pointing to a URL that does not have .do, it should just work fine - as long as you have the CGI script to receive that upload.
Krish baskar
Greenhorn

Joined: Dec 23, 2007
Posts: 10
Thanks for reply James..

you want to use a CGI to handle your uploads, and struts action should not handle your upload


Not exactly... I would like to replace my struts application instead of cgi server. But my client application should not know they submit to a different server. Let them think they submit to cgi server and i would like to handle in my struts application.

I have seen in many places submitting to htm is redirected to action classes and in the same way submitted to a" fake .cgi" will go to take my struts application...

James Ward
Ranch Hand

Joined: Apr 27, 2003
Posts: 263
In web.xml, your servlet mapping should look like this (note the addition of .cgi there in url pattern):


For the above to work you should be using servlet 2.5 and above.

For an earlier servlet specificiation (define it twice):



Now, any request with .cgi url pattern will be handled by struts.
Krish baskar
Greenhorn

Joined: Dec 23, 2007
Posts: 10
yeah... I did not use two <servlet-mapping>, only one is enough in my case, as this server will have only this action. So it works for me. Thanks for reply James...
 
GeeCON Prague 2014
 
subject: How to customize mapping in struts-config.xml ?