This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Context root and html paths

 
Tobia Scapin
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 445
1
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64843
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Tobia Scapin
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)?

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic