You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ma...@epamail.epa.gov on 2007/04/09 22:25:40 UTC

Simple Login demo issue

Hi all

I am trying to run the Simple Login demo for Struts 2. 
http://struts.apache.org/2.x/docs/simplelogin-with-session.html

I am using struts 2.0.6 with tomcat 5.5.23. "r5sis" is "context root" and 
"WebContent" is "Content Directory". I copied the struts jars to the 
"WebContent/WEB-INF/lib" folder. The jsp files are placed in 
"WebContent/WEB-INF/jsp" folder.

When I run "http://localhost:8080/r5sis/" it gives a 404 error. I think 
there is a problem in configuring the following files.

Following is my folder structure
+ WebContent
- + WEB-INF
   - + classes
      - struts.xml
   - + jsp
   - + lib
   - + src
   - web.xml
- index.jsp

Following are the source code.

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns=
"http://java.sun.com/xml/ns/j2ee" xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=
"http://java.sun.com/xml/ns/j2ee 
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
        <display-name>r5test</display-name>
        <filter>
                <filter-name>struts</filter-name>
                <filter-class>
org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
        </filter>
        <filter-mapping>
                <filter-name>struts</filter-name>
                <url-pattern>/*</url-pattern>
        </filter-mapping>
        <welcome-file-list>
                <welcome-file>index.jsp</welcome-file>
        </welcome-file-list>
</web-app>

struts.xml

<?xml version="1.0" encoding="UTF-8"?>
<struts>
        <!-- Include Struts 2 default (from Struts 2 JAR). -->
        <include file="struts-default.xml"/>

        <!-- Configuration for the default package. -->
        <package name="default" extends="struts-default">

        <!-- Default interceptor stack. -->
        <action name="login" class=
"gov.epa.r5sis.struts.action.LoginAction" >
            <result name="success" type="dispatcher">
/WEB-INF/jsp/welcome.jsp</result>
            <result name="error" type="redirect">/WEB-INF/jsp/login.jsp</
result>
        </action>

        <action name="logout2" class=
"gov.epa.r5sis.struts.action.LoginAction" method="logout" >
            <result name="success" type="redirect">/WEB-INF/jsp/login.jsp
</result>
        </action>

        <action name="logout" class=
"gov.epa.r5sis.struts.action.LogoutAction" >
            <result name="success" type="redirect">/WEB-INF/jsp/login.jsp
</result>
        </action>

        </package>
</struts>

index.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<% response.sendRedirect("login.action"); %>
</body>
</html>

The rest of the code is as same as the sample code given in the demo.

Please help me.

Vignesh 


Re: Simple Login demo issue

Posted by Jae K <in...@gmail.com>.
Hello Vignesh,
You should configure log4j, and look at both the tomcat's catalina.out log
file and log4j log file. The output of the log file should tell you what
went wrong. Let me know if you have trouble setting any of these up.

 - Jae

On 4/9/07, Manickam-Periaswamy.Vignesh@epamail.epa.gov <
Manickam-Periaswamy.Vignesh@epamail.epa.gov> wrote:
>
> Hi all
>
> I am trying to run the Simple Login demo for Struts 2.
> http://struts.apache.org/2.x/docs/simplelogin-with-session.html
>
> I am using struts 2.0.6 with tomcat 5.5.23. "r5sis" is "context root" and
> "WebContent" is "Content Directory". I copied the struts jars to the
> "WebContent/WEB-INF/lib" folder. The jsp files are placed in
> "WebContent/WEB-INF/jsp" folder.
>
> When I run "http://localhost:8080/r5sis/" it gives a 404 error. I think
> there is a problem in configuring the following files.
>
> Following is my folder structure
> + WebContent
> - + WEB-INF
>    - + classes
>       - struts.xml
>    - + jsp
>    - + lib
>    - + src
>    - web.xml
> - index.jsp
>
> Following are the source code.
>
> web.xml
>
> <?xml version="1.0" encoding="UTF-8"?>
> <web-app id="WebApp_ID" version="2.4" xmlns=
> "http://java.sun.com/xml/ns/j2ee" xmlns:xsi=
> "http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=
> "http://java.sun.com/xml/ns/j2ee
> http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
>         <display-name>r5test</display-name>
>         <filter>
>                 <filter-name>struts</filter-name>
>                 <filter-class>
> org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
>         </filter>
>         <filter-mapping>
>                 <filter-name>struts</filter-name>
>                 <url-pattern>/*</url-pattern>
>         </filter-mapping>
>         <welcome-file-list>
>                 <welcome-file>index.jsp</welcome-file>
>         </welcome-file-list>
> </web-app>
>
> struts.xml
>
> <?xml version="1.0" encoding="UTF-8"?>
> <struts>
>         <!-- Include Struts 2 default (from Struts 2 JAR). -->
>         <include file="struts-default.xml"/>
>
>         <!-- Configuration for the default package. -->
>         <package name="default" extends="struts-default">
>
>         <!-- Default interceptor stack. -->
>         <action name="login" class=
> "gov.epa.r5sis.struts.action.LoginAction" >
>             <result name="success" type="dispatcher">
> /WEB-INF/jsp/welcome.jsp</result>
>             <result name="error" type="redirect">/WEB-INF/jsp/login.jsp</
> result>
>         </action>
>
>         <action name="logout2" class=
> "gov.epa.r5sis.struts.action.LoginAction" method="logout" >
>             <result name="success" type="redirect">/WEB-INF/jsp/login.jsp
> </result>
>         </action>
>
>         <action name="logout" class=
> "gov.epa.r5sis.struts.action.LogoutAction" >
>             <result name="success" type="redirect">/WEB-INF/jsp/login.jsp
> </result>
>         </action>
>
>         </package>
> </struts>
>
> index.jsp
>
> <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
>     pageEncoding="ISO-8859-1"%>
> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> "http://www.w3.org/TR/html4/loose.dtd">
> <html>
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
> <title>Insert title here</title>
> </head>
> <body>
> <% response.sendRedirect("login.action"); %>
> </body>
> </html>
>
> The rest of the code is as same as the sample code given in the demo.
>
> Please help me.
>
> Vignesh
>
>