If I remember correctly, in Struts 1.x you could use Struts custom tag
library for HTML components, and the one for the form element was
<html:form/>. It had an attribute action, which required a value to be a
name of the single action from action-mappings in your
struts-config.xml. That was what Struts web-framework could do for you -
you shouldn't even bother about resulting URL.
Let us say you have the following action:
<action-mappings>
...
<!-- Resolves what action was performed and forwards full
request handling to it. -->
<action
path="/resolveLogin"
type="prj.web.actions.RedirectAction"
name="authenticationForm"
scope="request"
validate="false">
<forward
name="login"
path="/login.do"
contextRelative="false" />
<forward
name="failure"
path="/login.do"
contextRelative="false" />
</action>
...
</action-mappings>
Corresponding form would be:
<html:form action="resolveLogin" focus="username">
...
</html:form>
As you see, you don't have to think about final URL at all. So if your
problem is with appending context path, here is the solution - you don't
have to bother about it, because that's what Struts web framework is for.
--
aidas
JPJ wrote:
Thanks for the quick response. If I uderstood you correctly, the problem with
this solution is that I have more than one web application in my jboss
server. And I cannot deploy as ROOT for all application on the same server.
Should this be viewed as an issue of FORM tag implementation? I do not know
whether I am making a worthless statements but according my view we should
not prepend the web app context root to the action value in JSP while
rendering. Instead we should only prepend only the name space without
context root.
Any suggestions?
Thanks,
Jinzzz
Aidas Semezys wrote:
I guess the simplest way to achieve this is to deploy your application
as ROOT one under tomcat installations' webapps dir.
--
aidas
JPJ wrote:
Hi,
Is there anyway we can prevent the context root of the web application
from
prepending to the uri of an action. I know if we use the namespace then
the
url is formed by adding
ServerName+ContextRoot+NameSpace+ActionName+".action".
I am not specifying any namespace for my struts pacakge. But when I see
the
view source of the jsp my application context root(which is /webapp1) is
preppended to the action value (the URI). So my url is changed to
http://appserver:8080/webapp1/webapp1/Login.action(http://ServerName:port/WebAppContextRoot+/WebAppContextRoot/Action).
The URI is now /webapp1/Login.action where I expect /Login.action. This
created problem for my apache rewrite rules. Is there anyway I can avoid
the
webapp context root to prepend to my action value in jsp while rendring
the
page? I think this is happening while rendering the FORM tag.
I tried with namespace="/" and namespace="" in struts.xml and form tag
but
still the context root is getting appended to action value.
I am using struts2.1.6 and my application server is jboss4.x. I am using
empty namespace in the struts package. My application context is /webapp1
(in jboss-web.xml).
My jboss-web.xml is like
<jboss-web>
<security-domain flushOnSessionInvalidation="false"/>
<context-root>/webapp1</context-root>
</jboss-web>
My struts.xml file is as follows.
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="mypackage" extends="struts-default">
<interceptors>
<interceptor name="authentication"
class="com.abc.custominterceptors.SessionAuthINCR"/>
<interceptor-stack name="incrstack">
<interceptor-ref name="authentication" />
<interceptor-ref name="defaultStack" />
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="incrstack" />
<action name="Welcome" >
<result name="input">/pages/Login.jsp</result>
<result>/pages/Login.jsp</result>
</action>
<action name="Login" class="com.abc.action.LoginA">
<result name="input">/pages/Login.jsp</result>
<result >/pages/ListNames.jsp</result>
</action>
</package>
</struts>
My Login.jsp is like
<s:form name="loginForm" action="Login" method="post" theme="simple" >
...
...
</s:form>
The view source of Login.jsp looks like
<form name="loginForm" action="/webapp1/Login.action" method="post">
...
...
</form>
I appreciate your help in this as I tried a lot of options and read a lot
of
forums, but nowwhere this issue is raised.
Thanks,
Jinzzz
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org