struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thad Humphries <>
Subject redirecting from applet
Date Tue, 16 Dec 2003 23:11:52 GMT
I'm looking into reworking a Java application with Struts.  This application 
make frequent use of applets.  I need to avoid writing separate interfaces 
for JSPs and applets so I want my applets to call the Action servlets.

I started with a variation of Chapter 3's example from O'Reilly's "Programming 
Jakarta Struts".  No applets.  My login.jsp calls LoginAction which connects 
with a server application and stores the application object in the session.  
The next action called is GetScreenListAction which retrieves the application 
object from the session and returns a screen list.  That all works.

Now I substitute login_applet.jsp.  The applet does a POST via the Jakarta 
Commons HTTP client.  That works--my application's console file as well as 
println's in LoginAction show that I've logged in.  The GetScreenListAction 
gets called with a jsessionid but Struts redirects me to a login page as if 
I've never logged in.  Ideas?

The action in my struts-config.xml looks like:

      <forward name="Success" path="/action/getscreenlist" redirect="true"/>
      <forward name="Failure" path="/login.jsp" redirect="true"/>

The applet call looks like:
    HttpClient client = new HttpClient();
    PostMethod post_method = new PostMethod( actionURL );
    NameValuePair userName  = new NameValuePair( "userName", 
useridField.getText() );
    NameValuePair password  = new NameValuePair( "password", new String ( 
passwdField.getPassword() ) );
    NameValuePair appServer = new NameValuePair( "appServer", 
serverField.getText() );
    post_method.setRequestBody( new NameValuePair [] { userName, password, 
appServer } );
    client.executeMethod( post_method );

    byte[] postResponseBody = post_method.getResponseBody();

    StringTokenizer st = new StringTokenizer( post_method.getResponseHeader( 
"Location" ).toExternalForm() );
    String newURL = st.nextToken();

    getAppletContext().showDocument( new URL( newURL ) );

The URL the applet redirects to is 
I can see it in the applet's Java console via println and in the browsers URL 
navigation field.  So why do I get switched to login.jsp vs. the Success 
action like I do when this is all JSP?

Thad Humphries                 " religious test shall ever be required
Web Development Manager         as a qualification to any office or public
Phone: 540/675-3015, x225       trust under the United States." -Article VI

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message