| Author |
Newbie Question
|
Mike London
Ranch Hand
Joined: Jul 12, 2002
Posts: 948
|
|
I am trying to get a basic Login form to work. What I have done is to create an "index.jsp" in the root of the Webapps folder that I'm trying to redirect to a page in the form directory under Webapp -> form/login.jsp. However, when I try to get this to work, I get a newbie error like the one below: javax.servlet.ServletException: Cannot create rewrite URL: java.net.MalformedURLException: Cannot retrieve ActionForward named index ------------------- In my index.jsp page, I put a forwarder like this: <html:link forward="index" /> ------------------- Then, in the struts-config.xml, I have this: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd"> <struts-config> <data-sources /> <form-beans > <form-bean name="loginForm" type="net.test.struts.form.LoginForm" /> </form-beans> <global-exceptions /> <global-forwards > <forward name="success" path="/form/LoginSuccess.jsp" /> <forward name="failure" path="/form/LoginFailure.jsp" /> </global-forwards> <action-mappings > <action attribute="loginForm" input="/form/login.jsp" name="loginForm" path="/login" scope="request" type="net.test.struts.action.LoginAction" /> </action-mappings> <message-resources parameter="net.test.struts.ApplicationResources" /> </struts-config> ---------------------- I tried adding a global forwarder, but that didn't work, at least the way I did it. What do I need to change to get this to work? Thanks in advance to all. Mike
|
 |
Merrill Higginson
Ranch Hand
Joined: Feb 15, 2005
Posts: 4864
|
|
Try it this way: making sure this is the only line of code in the JSP aside from the taglib declarations. Note: it's better to use names like "success" and "failure" as local forwards. A global forward should be named something like "login". [ February 04, 2007: Message edited by: Merrill Higginson ]
|
Merrill
Consultant, Sima Solutions
|
 |
Mike London
Ranch Hand
Joined: Jul 12, 2002
Posts: 948
|
|
Thanks for your reply, but this isn't what I'm trying to do. Instead, I'm trying to redirect from index.jsp (in the web app root) to the form/login.jsp page. THEN, if the login is successful, I'd redirect (based on the loginAction class) to either the success or failure pages. Can you explain how to do this? Thanks. M
|
 |
Merrill Higginson
Ranch Hand
Joined: Feb 15, 2005
Posts: 4864
|
|
|
Just create a global forward named "login" that points to /form/login.jsp and specify <logic:forward name="login" /> in your index.jsp.
|
 |
Mike London
Ranch Hand
Joined: Jul 12, 2002
Posts: 948
|
|
Thanks. I can't believe I missed that obvious error. Thanks also to your correction to my link in the index.jsp page. I guess I copied one that wasn't correct from somewhere. I also fixed a problem where the "name" of the email address field was "email" , not name="emailAddress". Once I fixed that too, all worked OK. Thanks again for your terrific help!!! M
|
 |
 |
|
|
subject: Newbie Question
|
|
|