[Logo] Mentawai Forum - Mentawai Web Framework
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 

Forum Read-Only! Check the new site and forum here!

Authentication doesn't work  XML
Forum Index -> General Comments
Author Message
flaviosf



Joined: 21/01/2009 15:43:16
Messages: 2
Offline

Hi all.

I'm trying run the authentication project downloaded from the Mentawai web site, but it does'n work.

I type username and password correct, but the application redirects to login.jsp, not to welcome.jsp as it has to be.

LoginAction.java:
Code:
 public class LoginAction extends BaseLoginAction {
 	
 	public String execute() throws Exception {
 		String user = input.getStringValue("username");
 		String pass = input.getStringValue("password");
 		
 		if (user == null || user.trim().equals("")) 
 			return ERROR;
 		
 		if (pass == null || pass.trim().equals("")) 
 			return ERROR;
 				
 		if (!user.equals("flavio") || !pass.equals("flavio")) 
 			return ERROR;
 		
 		setUserSession(user);
 		
 		return SUCCESS;
 	}	
 }
 


ApplicationManager.java:
Code:
 
 import org.mentawai.core.*;
 import org.mentawai.filter.*;
 import org.mentawai.action.*;
 
 import examples.authentication.LoginAction;
 
 public class ApplicationManager extends org.mentawai.core.ApplicationManager {
 	
 	public void loadActions() {
 		
 		addGlobalFilter(new AuthenticationFilter());
 		addGlobalConsequence(AuthenticationFilter.LOGIN, new Redirect("/login.jsp"));
 		
 		ActionConfig ac = new ActionConfig("Login", LoginAction.class);
 		ac.addConsequence(LoginAction.SUCCESS, new Redirect("/welcome.jsp"));
 		ac.addConsequence(LoginAction.ERROR,  new Forward("/login.jsp"));
 		addActionConfig(ac);
 		
 		ac.addFilter(new RedirectAfterLoginFilter());
 		ac.addConsequence(RedirectAfterLoginFilter.REDIR, new Redirect()); // dynamic redirect
         
         ac = new ActionConfig("/Logout", LogoutAction.class);
         ac.addConsequence(LogoutAction.SUCCESS, new Redirect("/index.jsp"));
         addActionConfig(ac);
 	}
 }
 


web.xml:
Code:
 <?xml version="1.0" encoding="ISO-8859-1"?>
 
 <!DOCTYPE web-app
     PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
     "http://java.sun.com/dtd/web-app_2_3.dtd">
 
 <web-app>
   	
 	<display-name>Hello Mentawai</display-name>
 	<description>
 		Hello World from the Mentawai Web Framework
 	</description>
    
 	<servlet>
         <servlet-name>Controller</servlet-name>
         <servlet-class>org.mentawai.core.Controller</servlet-class>
         <init-param>
         	<param-name>applicationManager</param-name>
         	<param-value>ApplicationManager</param-value>
     	</init-param> 
 		<load-on-startup>1</load-on-startup>		
     </servlet>
 
     <!-- You must choose an extension to indicate a mentawai action -->
     <servlet-mapping>
         <servlet-name>Controller</servlet-name>
         <url-pattern>*.mtw</url-pattern>
     </servlet-mapping>
 
 </web-app>
 


What's wrong?

Thanks

Flávio
 
Forum Index -> General Comments
Go to:   
Powered by JForum 2.1.6 © JForum Team