Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Struts
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Struts
submitting correct username and password, it again come in login.jsp
Babu Singh
Ranch Hand
Posts: 84
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
i am submit username and password in login.jsp, after submit correct username and password, it again come in login.jsp.
Here some files:
Struts.xml:
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <constant name="struts.enable.DynamicMethodInvocation" value="false" /> <constant name="struts.devMode" value="false" /> <include file="mypackage.xml"/> <!-- Add packages here --> </struts>
mypackage.xml:
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <package name="mypackage" namespace="/" extends="tiles-default"> <action name="Login" class="com.struts2.LoginAction"> <result name="input">/login.jsp</result> <result name="success">/Home.jsp</result> <result name="error">/login.jsp</result> </action> <action name="customer" class="com.struts2.CustomerAction"> <result name="success" type="tiles">/logged.success.tiles</result> <result name="input" type="tiles">/index.tiles</result> </action> </package> </struts>
LoginAction.java:
package com.struts2; import java.sql.*; import com.opensymphony.xwork2.ActionSupport; public class LoginAction extends ActionSupport{ private static final long serialVersionUID = 1L; public String execute() throws Exception { if (this.username_txt.equals("school") && this.password_txt.equals("school")) { System.out.println("now going for success********************"); return "success"; } else { System.out.println("here for error------------------"); addActionError(getText("error.login")); return "error"; } } private String username_txt; private String password_txt; public String getPassword_txt() { return password_txt; } public void setPassword_txt(String password_txt) { this.password_txt = password_txt; } public String getUsername_txt() { return username_txt; } public void setUsername_txt(String username_txt) { this.username_txt = username_txt; } }
login.jsp:
<%@ page contentType="text/html; charset=UTF-8" %> <%@ taglib prefix="s" uri="/struts-tags" %> <html> <head> <title>Login page</title> </head> <body> <s:form action="Login"> <s:textfield key="username_txt"/> <s:password key="password_txt" /> <s:submit/> </s:form> </body> </html>
please suggest.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
The requested resource () is not available
Exception while running struts2 application.
Form Validation using xml in struts2
Struts2: Cannot submit action after a second validation attempt.
Struts 2.0 application not working in WAS 6.1 server
More...