aspose file tools*
The moose likes Struts and the fly likes Context root and html paths Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Context root and html paths" Watch "Context root and html paths" New topic
Author

Context root and html paths

Tobia Scapin
Greenhorn

Joined: Mar 19, 2010
Posts: 5
Hello i'm new of struts and i have a strange problem, i hope you can help me.

I have an EAR application with this context:

http://mydomain/myear/

In a weblogic server. I installed inside two indipendent WAR application

war1 with "app1" context root (set in application.xml)
war2 with "app2" context root.

I have to sat that i can not modify any weblogic configuration, i have a single server in that domain with a fixed root (mydomain/myear)
The application server answer correctly here:


http://mydomain/myear/app1 -> to the war1
http://mydomain/myear/app2 -> to the war2

My trouble is when struts and his tiles create the html path in the views, becuse it thinks that the root is "app1" and not "myear/app1".
Infact the homepage correctly started but inside the html:form tag had this action path: "/app1/MyAction" and obviously it will send to http://mydomain/app1/MyAction out of my application.
How can i setup struts to add "myear/" before the context root when it makes the html paths?

Thank you.



Rajkamal Pillai
Ranch Hand

Joined: Mar 02, 2005
Posts: 443
    
    1

Hi,

You can use a request.getContextPath() along with the URL. But my understanding is that if you use html:xxx tags Struts takes care of adding the context path by default? Check out this post

Javaranch forum link

Cheers,
Raj.
Tobia Scapin
Greenhorn

Joined: Mar 19, 2010
Posts: 5
Thanks for your answer.
It can be, but i must change every page... I hope there is some configuration... or no?

This is a big application that before was deployed in a domaim root (http://mydomain/app1) so everything worked correctly... but now it moves to a sub-folder of the domain, that it is still in a virtualserver root (server side the context root is corret), but i need to map the path action in html with the context-root (already done by struts) "app1" but prepending "myear", exists some configuration attribute?

Thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61224
    
  66

See the JSP FAQ for more information on this. And yes, you need to fix the URLs -- there's no config to do so. How could there be?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Tobia Scapin
Greenhorn

Joined: Mar 19, 2010
Posts: 5
Maybe it did not well explain...
I use this tag: <html:form action="/MyAction"> and /MyAction refer to an action in the struts config.
In generated html this became: <form action="/app1/MyAction" > so struts automatically (correctly) prepend to action the context-root of my app.
There is no way to use a relativePath or to manually set the context-path (/myear/app1 instead of /app1)?

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Context root and html paths