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

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Newbie Question" Watch "Newbie Question" New topic

Newbie Question

Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1126
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: 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" "">

<data-sources />
<form-beans >
<form-bean name="loginForm" type="net.test.struts.form.LoginForm" />

<global-exceptions />
<global-forwards >

<forward name="success" path="/form/LoginSuccess.jsp" />
<forward name="failure" path="/form/LoginFailure.jsp" />


<action-mappings >
type="net.test.struts.action.LoginAction" />


<message-resources parameter="net.test.struts.ApplicationResources" />

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.

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 ]

Consultant, Sima Solutions
Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1126
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?


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: 1126
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!!!

I agree. Here's the link:
subject: Newbie Question
It's not a secret anymore!