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:
<action
path="/login"
type="com.optix.struts.action.LoginAction"
scope="request"
name="loginForm"
input="/login_applet.jsp">
<forward name="Success" path="/action/getscreenlist" redirect="true"/>
<forward name="Failure" path="/login.jsp" redirect="true"/>
</action>
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();
The URL the applet redirects to is
http://<server>/action/getscreenlist;jsessionid=2EB33E628562558896EDCDC4B6E372AB
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 "...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]