File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes How to call a .do directly? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to call a .do directly?" Watch "How to call a .do directly?" New topic

How to call a .do directly?

j luft

Joined: Oct 14, 2010
Posts: 3
Why is it when I call a .do method directly,(http://myserver/myapp/ it errors out because there is no session?? If I launch the app by default (
(http://myserver/myapp) ,then navigate to the .do I want, it works since there is a session. What am I doing wrong that it isn't creating the session ???
Ankit Garg

Joined: Aug 03, 2008
Posts: 9466

it errors out because there is no session?

Can you elaborate on this more please. Where exactly do you get the error. If its in your Action code, then please show us the code of your action...

SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
j luft

Joined: Oct 14, 2010
Posts: 3
I have a request processor that I added to forward people to the home page when their session is invalid... I added a line to allow the one action through that I want to be accessed directly (users are sent a link via email).

protected boolean processPreprocess(HttpServletRequest request, HttpServletResponse response) {
if (request.isRequestedSessionIdValid() == false) {
try {
Log.debug(this.getClass(), "session is no longer valid "+request.getRequestURL());
StringBuffer url = request.getRequestURL();

if ( url != null && url.indexOf("/") > 0 ) {
return (true);
} else {
doForward("/index.jsp", request, response);

It allows me to get to the page now, but the session is still invalid(puts out the debug). When I get to the page, some of the stuff on the page does not render (html:rewrite for images etc)
and the form is not filled out. When I view source on the page, all the html: tag rendered with jsessionid=6d356793f802c2ba67c5f27bca8a56ea693130656f3fee2cf104b9f03ef56cf5 appended to the end of it... If I launch the app going to the home page first, then go to this action, everything works ok.... How do I get it to render correctly when I go directly to that action in a new browser?
Here is the definition of the action in my struts config;
<action path="/license"
<forward name="continue" path=".tile.licenseAgree"/>

I agree. Here's the link:
subject: How to call a .do directly?
It's not a secret anymore!