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.
My problem is similar to one discussed about a month ago (http://marc.theaimsgroup.com/?l=jakarta-commons-user&m=106690605015755&w=2) but I am trying to do the opposite: I have an applet that logs into a Struts application. Now I need to pass that JSESSIONID information back to my next servlet call. Elsewhere in my application, I expect to mix applets, servlets, and JSPs (in the application I'm looking to replace, applets frequently call JSPs to send or receive data). 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 my Struts LoginAction show that I've logged in. The GetScreenListAction gets called with the JSESSIONID but Struts redirects me to a login page as if I've never logged in. Ideas? Here's what I've tried so far: When 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() ); st.nextToken(); String newURL = st.nextToken(); getAppletContext().showDocument( new URL( newURL ) ); post_method.releaseConnection(); ... } I'm sent to my logon.jsp (the no session path) instead of the GetScreenListAction. This even though the URL contains the JSESSIONID. (The URL the applet redirects to is http://<server>/action/getscreenlist;jsessionid=2EB33E628562558896EDCDC4B6E372AB) However, if instead of "getAppletContext().showDocument( new URL( newURL ) );" I try // getAppletContext().showDocument( new URL( newURL ) ); GetMethod get_method = new GetMethod( newURL ); client.executeMethod( get_method ); byte[] getResponseBody = get_method.getResponseBody(); get_method.releaseConnection(); System.err.println( " getResponseBody: " + new String(getResponseBody) ); post_method.releaseConnection(); I see the output of GetScreenListAction in getResponseBody. That's what I want but I want it to appear in my browser, not come back to my applet. (No, the application doesn't have to work this way but it is indicative of the way it works now. In some case, an acceptable interface is not possible thru HTML.) Any ideas? Thanks! -- Thad Humphries "...no 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
