aspose file tools
The moose likes Struts and the fly likes context and action classes Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Frameworks » Struts
Reply Bookmark "context and action classes" Watch "context and action classes" New topic
Author

context and action classes

venkata kadiyala
Greenhorn

Joined: May 03, 2004
Posts: 7
Hi all,
Can anyone please reply to a small problem that i've got.
How can i reference a JSP in B.war from a my struts application A.war?
Is it possible to do it either through forward tag in struts-config.xml or in the action class where we use requestDispatcher().
If we're going to use requestDispatch(), how can i get the "servlet context" of the B.war.
please help.
venkat
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4725

http://jakarta.apache.org/struts/userGuide/configuration.html
To quote,

There are two basic methods to switching from one module to another. You can either use a forward (global or local) and specify the contextRelative attribute with a value of true, or you can use the built-in org.apache.struts.actions.SwitchAction.
Here's an example of a global forward:

...
<struts-config>
...
<global-forwards>
<forward name="toModuleB"
contextRelative="true"
path="/moduleB/index.do"
redirect="true"/>
...
</global-forwards>
...
</struts-config>


A good workman is known by his tools.
venkata kadiyala
Greenhorn

Joined: May 03, 2004
Posts: 7
Thanks Marc for your suggestion. I looked into the document and made the appropriate changes but to my misery it still didnt work.
Let me explain to you through an example so that you can provide me with some suggestion of what I'm doing wrong here.
I've this "testweb" and "changepass" modules in my WSAD. Both are different web-apps but run on the same server WAS5.0
Now in the "testweb" module when the forward is "success", it has to get redirected to "changepass.do" but thats not happening. The browser is returning me with an error
"Invalid path"
My struts config file for "testweb" module is as shown below:
<forward name="success"
contextRelative="true"
path="/ChangePasswordWeb/changepass.do"
redirect="true"/>
Can you provide me with any suggestions??
Thanks for your help
venkat
venkata kadiyala
Greenhorn

Joined: May 03, 2004
Posts: 7
Sorry to trouble you guys I think I solved that.
But theres one tiny problem
I want to send the request object of "testweb" to the "changepass" web module.
But the problem is i'm getting the value of this as null.
Is there are specific way pass the request object from one web-app to another web-app?
venkat
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4725

I replied to this yesterday but I do not see my post here now.
Try putting your object(s) in session. The redirect should only cause you to lose request because the redirect is making two requests and the first request does not pass anything to the second.
I do not believe you should lose session.
You can remove your object(s) from session when they are no longer needed.
venkata kadiyala
Greenhorn

Joined: May 03, 2004
Posts: 7
Thanks for your reply Marc,
But the problem if i use session to pass around values is that
The other application (B.war) is expecting data to retrieved from a request object and NOT a session object. I cant change the code in that application so somehow I should only pass the request object to that app.
B.war is expecting request.getAttribute(...) and NOT
session.getAttribute(...)
Hope I explained my problem clearly,
Thanks,
venkat
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4725

Can't modify the other app? Grrr.
That puts a damper on things. I'll keep it in mind today. Hopefully something will work.
venkata kadiyala
Greenhorn

Joined: May 03, 2004
Posts: 7
Hi Marc,
Did u come up with any solution to my problem?
venkat
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4725

Sorry. I could not think of anything.
I am surprised that no one else has posted to this thread.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: context and action classes
 
Similar Threads
servlet context in struts Action class
Access jsp file under WEB-INF directly
Accessing Servlet from different war Files
Ant related problem
How to get ServletConfig and ServletContexts in Action class of struts