You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Kevin Duffey <kd...@buymedia.com> on 2000/07/25 05:34:51 UTC

How to use a CONTEXT value inside the action.xml to specify forwarding to a page in a context (multiple web apps at once)

Hi,

I appear to have come across a need to allow the action.xml file contain
"dynamic" data. haha..not sure how to explain this. I have 3 web-apps
running (servlet 2.2 deployment only). Each app has its own context path to
access it, so that all 3 may maintain their own data in their context. Thus,
I have app /A, /B and /C so requests to /A/myresource do NOT interfere with
/B/resource. All 3 apps point to the same one WWW root dir, which is ok. The
problem I am having is that in action.xml, I specify a /path/page.jsp to
forward to. However, in order to access /A, /B or /C depending on some
condition, I need a way to specify /A/path/page.jsp and I am not quite sure
how this is possible with Struts.

So I ask you, oh great Struts gurus, how do I get Struts ActionServlet to
use a context without having to override it myself?

Thanks.


RE: How to use a CONTEXT value inside the action.xml to specify forwarding to a page in a context (multiple web apps at once)

Posted by Kevin Duffey <kd...@buymedia.com>.
Ok..thats what I thought.


> -----Original Message-----
> From: Craig R. McClanahan [mailto:Craig.McClanahan@eng.sun.com]
> Sent: Monday, July 24, 2000 8:57 PM
> To: struts-user@jakarta.apache.org
> Subject: Re: How to use a CONTEXT value inside the action.xml to specify
> forwarding to a page in a context (multiple web apps at once)
>
>
> Kevin Duffey wrote:
>
> > Hi,
> >
> > I appear to have come across a need to allow the action.xml file contain
> > "dynamic" data. haha..not sure how to explain this. I have 3 web-apps
> > running (servlet 2.2 deployment only). Each app has its own
> context path to
> > access it, so that all 3 may maintain their own data in their
> context. Thus,
> > I have app /A, /B and /C so requests to /A/myresource do NOT
> interfere with
> > /B/resource. All 3 apps point to the same one WWW root dir,
> which is ok. The
> > problem I am having is that in action.xml, I specify a /path/page.jsp to
> > forward to. However, in order to access /A, /B or /C depending on some
> > condition, I need a way to specify /A/path/page.jsp and I am
> not quite sure
> > how this is possible with Struts.
> >
> > So I ask you, oh great Struts gurus, how do I get Struts
> ActionServlet to
> > use a context without having to override it myself?
> >
>
> You will not be able to use RequestDispatcher.forward() -- with or without
> Struts -- to cross web application boundaries.  This is because
> the request path
> that you specify is context relative.  Your only option will be to use
> sendRedirect() instead for these types of links, and specify a
> request path that
> is either absolute or host-relative (instead of context-relative).
>
> >
> > Thanks.
>
> Craig
>
>
>


Problem with run Structs example

Posted by Yuan Jun <yj...@sunjapan.co.jp>.
deployed expamle.war under jrun3.0
when excute it shows errors below

i checked struts.jar and it did contant
org.apache.struts.taglib.LocalStrings, what should i do?

500 Internal Server Error
/StrutsSample/:

javax.servlet.ServletException: Exception thrown on line '6' from page
'C:\\Program
Files\\Allaire\\JRun\\servers\\default\\Struts-Example\\index.jsp'.
java.lang.ExceptionInInitializerError: java.util.MissingResourceException:
Can't find resource for base name org.apache.struts.taglib.LocalStrings,
locale ja_JP
	at java.util.ResourceBundle.getBundle(ResourceBundle.java:423)
	at java.util.ResourceBundle.getBundle(ResourceBundle.java:339)
	at org.apache.struts.util.MessageResources.(MessageResources.java:102)
	at
org.apache.struts.util.MessageResources.getMessageResources(MessageResources
.java:579)
	at org.apache.struts.taglib.MessageTag.(MessageTag.java:164)
	at java.lang.Class.newInstance0(Native Method)
	at java.lang.Class.newInstance(Class.java, Compiled Code)
	at
allaire.jrun.jsp.JRunJSPStaticHelpers.createTagHandler(JRunJSPStaticHelpers.
java:47)
	at jrun__index2ejspa._jspService(jrun__index2ejspa.java:39)
	at allaire.jrun.jsp.HttpJSPServlet.service(HttpJSPServlet.java:40)




Problem with option tag

Posted by Robert Edgar <ro...@hkstar.com>.
Till now I have been using struts from 1/7,  just installed the 17/7  build
and hit an error in the option tag where it says it cant find a getter
method for a property called Values which is where I supply the values
attributes for the option tags. ( I have a bean with two properties, Values
and Labels which are both ArrayLists).

I double checked and swapped back in the old stuts lib and it works OK, so I
havent changed any of my code just switched libs.

Any thoughts on what the problem might be or what has changed

Rob



RE: How to use a CONTEXT value inside the action.xml to specify forwarding to a page in a context (multiple web apps at once)

Posted by Kevin Duffey <kd...@buymedia.com>.
On that note...

What if my site is set up like so...I have a web app for apples, oranges and
bananas. All three use the same /www root files (jsp pages). In those jsp
pages I have some scriplet code that basically says if the path has a
/apple/ in it, display this. If it has a /oranges/ in it, do this and if it
has /bananas/ in it, display this instead. All 3 web apps use the same "jsp"
pages, so each page only needs to be changed once for all 3 web-apps to be
affected. However, each app needs its own context to make absolutley sure
incase a use is on /bananans/ and hits the BACK button into a previous page,
/apples/, that because they use the same JSP pages data is not
"cross-talked" across the pages for different contexts. Its hard to explain,
but on our site we have 3 types, each needing separate "private" data pools
for each client (3 sessions for each one login), but all 3 using the same
set of pages since they are identically displayed (all 3 apps are very
similar in nature with slight differences in displays depending on the
specific app).


I want links to reflect the specific app they are in. If they switch to
/apples/, all links show /apples/ instead of say /oranges/ or /bananas/.
That is easy to do. In my JSP pages I have them all include the same one
header.inc file (inline it). In there, I have scriplet code that simply does
something like

<%
if( request.getRequestURI().indexOf("/apples/") >= 0 ) {
%>
<h1>APPLES</h1>
<% } else { %>
<h2>ORANAGES OR BANANAS</h2>
<% } %>

This is simple enough for displaying.

My main problem right now is not what clients need..they would only be
logged in to one of the 3. But our "admin" (customer support people really)
need to be logged in to all 3 of them at the same time, using 3 separate
windows. Because cookies from one machine limit the user to one browser
window (in terms of session data being stored via a cookie session id), I
decided to use 3 separate web apps, so that even though the one
client/browser returns the same one cookie id value, the server has 3
separate sessions, one in each context. So, on the admin site, I need to log
in the user one time, but really I need to create 3 separate contexts at one
time. I am doing this like so:

inside the login method I have:

URL url1 = new
URL("/apples/Login.do?command=3&LoginName=xxxx*LoginPassword=xxx");
url1.openConnection();
url1.getContent();

etc..

I do this for the other two as well, substituting /apples/ for /oranges/ and
/bananas/.

The method called by command==3 is:

someMethdo(HttpServletRequest request)
{
  request.getSession(true).setAttribute("ClientSession", someObject);
}

So now..the problem is, inside any page when I do /apples/page.jsp, the
object (someObject) should exist in the /apples/ web-app session for that
client..but it does not. I think the reason is the url1.getContent() is
either not sending the same cookie as the browser is, thus when I attempt to
use my browser "after" the login method creates the 3 contexts, the session
ID is invalid..and thus does not access the same context/session that was
created in the url1.getContent() call. Ofcourse, if I could manually set the
jsessionid cookie key that is used to the same cookie value the browser
would return (if thats possible), this might work.

So...I leave off with that. Any ideas?

Thanks.


Re: How to use a CONTEXT value inside the action.xml to specify forwarding to a page in a context (multiple web apps at once)

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Kevin Duffey wrote:

> Hi,
>
> I appear to have come across a need to allow the action.xml file contain
> "dynamic" data. haha..not sure how to explain this. I have 3 web-apps
> running (servlet 2.2 deployment only). Each app has its own context path to
> access it, so that all 3 may maintain their own data in their context. Thus,
> I have app /A, /B and /C so requests to /A/myresource do NOT interfere with
> /B/resource. All 3 apps point to the same one WWW root dir, which is ok. The
> problem I am having is that in action.xml, I specify a /path/page.jsp to
> forward to. However, in order to access /A, /B or /C depending on some
> condition, I need a way to specify /A/path/page.jsp and I am not quite sure
> how this is possible with Struts.
>
> So I ask you, oh great Struts gurus, how do I get Struts ActionServlet to
> use a context without having to override it myself?
>

You will not be able to use RequestDispatcher.forward() -- with or without
Struts -- to cross web application boundaries.  This is because the request path
that you specify is context relative.  Your only option will be to use
sendRedirect() instead for these types of links, and specify a request path that
is either absolute or host-relative (instead of context-relative).

>
> Thanks.

Craig