<?xml version="1.0" encoding="Shift_JIS"?>
<!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>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>2</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>
<taglib>
<taglib-uri>/tags/struts-bean</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/tags/struts-html</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/tags/struts-logic</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/tags/struts-nested</taglib-uri>
<taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/tags/struts-tiles</taglib-uri>
<taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
</taglib>
<!--
<taglib>
<taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
<taglib-location>/WEB-INF/c.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jstl/fmt</taglib-uri>
<taglib-location>/WEB-INF/fmt.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jstl/sql</taglib-uri>
<taglib-location>/WEB-INF/sql.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jstl/x</taglib-uri>
<taglib-location>/WEB-INF/x.tld</taglib-location>
</taglib>
-->
</web-app>
struts-config.xml:
<?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>
</data-sources>
<form-beans>
<form-bean name="loginform" type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="username" type="java.lang.String"></form-property>
<form-property name="password" type="java.lang.String"></form-property>
</form-bean>
</form-beans>
<global-exceptions>
</global-exceptions>
<global-forwards>
</global-forwards>
<action-mappings>
<action path="/login" type="com.test.struts.LoginAction" name="loginform" validate="true" input="/login.jsp">
<forward name="success" path="/welcome.jsp"></forward>
<forward name="failure" path="/login.jsp"></forward>
</action>
</action-mappings>
<controller locale="true" processorClass="org.apache.struts.tiles.TilesRequestProcessor"/>
<message-resources parameter="ApplicationResources"/>
<plug-in className="org.apache.struts.tiles.TilesPlugin">
<set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml"/>
<set-property property="moduleAware" value="true"/>
</plug-in>
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
</plug-in>
</struts-config>
login.jsp :
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-nested" prefix="nested" %>
<html:html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Cp1252"/>
<title></title>
</head>
<body bgcolor="yellow">
<center>
<html:errors/>
<bean:message key="welcome.message"/>
<html:form method="POST" action="login">
<bean:message key="username"/><html:text property="username"></html:text><br><br>
<bean:message key="password"/><html:text property="password"></html:text><br><br>
<html:submit><bean:message key="register.submit"/></html:submit>
</html:form>
</center>
</body>
</html:html>
LoginAction.java
package com.test.struts;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.validator.DynaValidatorForm;
/**
*
* @author Mallik
*
*/
/**
* LoginAction Class
*/
public class LoginAction extends Action {
/**
* Action class execute method
*/
public ActionForward execute(ActionMapping actionMapping,ActionForm actionForm,HttpServletRequest request,HttpServletResponse response)throws Exception{
String responseKey="failure";
DynaValidatorForm dynaValidatorForm=(DynaValidatorForm) actionForm;
String user=(String)dynaValidatorForm.get("username");
String pwd=(String)dynaValidatorForm.get("password");
if(user.equals(pwd))
responseKey="success";
return actionMapping.findForward(responseKey);
}
}
welcome.jsp :
<%@ page contentType="text/html; charset=Cp1252" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-nested" prefix="nested" %>
<html:html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Cp1252"/>
<title></title>
</head>
<body bgcolor="green">
<h1><bean:message key="welcome"/></h1>
</body>
</html:html>
ApplicationResources_it.properties :
welcome.message=Dare if benevenuato all aperatoreitaliano(in english:welcome to italian user)
welcome=<b>Dare if benevenuato all aperatoreitaliano</b>
username=<b>nome de operatore</b>
password=<b>parola de ordine</b>
register.submit=registero
errors.required=<li><i>if compo di{0}non puo essere vuoto</i></li>
errors.minlength=<li><i>la {0}non puo essere vuoto {2} carreteri.</i></li>
ApplicationResources_en.properties :
welcome.message = welcome to english user
welcome=<b>Hello english user welcome to our website</b>
username=<b>username</b>
password=<b>password</b>
register.submit=register
errors.required=<li><i>{0}field cannot be empty.</i></li>
errors.minlength=<li><i>{0}cannot be lessthan {2} charecters.</i></li>
9 comments:
It's an amazing piece of writing for all the online viewers; they
will obtain advantage from it I am sure.
My homepage ... greencoffeebeanpurediet.com ()
Wow, that's what I was exploring for, what a stuff!
existing here at this blog, thanks admin of this web page.
Have a look at my weblog: http://greencoffeebeandiets.net
Hello to all, how is everything, I think every one is getting more from this web page, and your views are nice designed for new users.
Review my page :: http://garciniacambogiaselectblogs.com
Its such as you learn my thoughts! You appear to know a
lot approximately this, like you wrote the guide in it or something.
I believe that you simply could do with some p.c.
to drive the message home a bit, however other than that,
that is wonderful blog. A fantastic read. I will certainly be back.
My weblog :: Hydroface Reviews
hey there and thank you for your information – I have certainly
picked up anything new from right here. I did however expertise several technical issues using this
web site, since I experienced to reload the web site lots of times previous to I could
get it to load properly. I had been wondering if
your hosting is OK? Not that I'm complaining, but sluggish loading instances times will
often affect your placement in google and can damage your high quality score if ads and marketing with Adwords.
Anyway I'm adding this RSS to my email and can look out for much more of your respective intriguing content.
Make sure you update this again soon.
my web blog Enemarex Lift Supplement
What's Taking place i am new to this, I stumbled upon this I've found It positively useful and it has aided me out loads.
I hope to contribute & help other users like its aided me.
Great job.
Here is my page; online spiele kostenlos ohne download
You have a great web site! Do you update it usually?
Will you care if I talk about this site with friends
with fb?
my blog ipad for free
Hi mates, its impressive piece of writing about tutoringand fully explained, keep it
up all the time.
Feel free to visit my site - garcinia cambogia select
()
Thank you for your complex article! Here is a very good online tool that works perfectly with properties: https://poeditor.com/. You just need to create an account and upload your language file and the translation interface will help you through your work.
Post a Comment