Commit a06d1ee2 authored by Sowmik's avatar Sowmik

initial commit

parents
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.8.0_71">
<attributes>
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v8.5">
<attributes>
<attribute name="owner.project.facets" value="jst.web"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="lib" path="C:/Users/Dohatec/Documents/MySQLJDBC/mysql-connector-java-8.0.26/mysql-connector-java-8.0.26.jar"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>test</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
</natures>
</projectDescription>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry excluding="**/bower_components/*|**/node_modules/*|**/*.min.js" kind="src" path="WebContent"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
<attributes>
<attribute name="hide" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
<classpathentry kind="output" path=""/>
</classpath>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="test">
<wb-resource deploy-path="/" source-path="/WebContent" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
<property name="context-root" value="test"/>
<property name="java-output-path" value="/test/build/classes"/>
</wb-module>
</project-modules>
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<runtime name="Apache Tomcat v8.5"/>
<fixed facet="wst.jsdt.web"/>
<fixed facet="jst.web"/>
<fixed facet="java"/>
<installed facet="java" version="1.8"/>
<installed facet="jst.web" version="3.1"/>
<installed facet="wst.jsdt.web" version="1.0"/>
</faceted-project>
org.eclipse.wst.jsdt.launching.baseBrowserLibrary
\ No newline at end of file
Window
\ No newline at end of file
Manifest-Version: 1.0
Class-Path:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
"http://tiles.apache.org/dtds/tiles-config_2_0.dtd">
<tiles-definitions>
<definition name="login" template="/layoutManager.jsp">
<put-attribute name="title" value="Login Page"/>
<put-attribute name="body" value="/login.jsp"/>
</definition>
<definition name="registration" template="/layoutManager.jsp">
<put-attribute name="title" value="Registration Page"/>
<put-attribute name="body" value="/register.jsp"/>
</definition>
<definition name="welcome" template="/layoutManager.jsp">
<put-attribute name="title" value="Welcome Page"/>
<put-attribute name="body" value="/welcome.jsp"/>
</definition>
</tiles-definitions>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<display-name>test</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>
struts2
</filter-name>
<filter-class>
org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>
org.apache.struts2.tiles.StrutsTilesListener
</listener-class>
</listener>
</web-app>
\ No newline at end of file
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!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=UTF-8">
<title>Test project title</title>
</head>
<body>
<h1>Home Page</h1>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
<a href="login.jsp">Login</a>
<a href="register.jsp">Register</a>
</body>
</html>
\ No newline at end of file
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<!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=UTF-8">
<title>Login</title>
</head>
<body>
<h3>User Login</h3>
<form action="login" method="post">
<pre>
<input type="text" name="email" placeholder="Please Enter Your Email" required/>
<input type="password" name="password" placeholder="Enter Password" required/>
<input type="submit" name="sub" value="Login"/>
</pre>
<%
String str = (String) request.getAttribute("message");
if(str!=null){
out.print(str);
}
%>
</form>
<a href="/registration.jsp">Register</a>
</body>
</html>
\ No newline at end of file
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<!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=UTF-8">
<title>User Registration Title</title>
</head>
<body>
<h3>User Registration</h3>
<form action="register" method="post">
<pre>
<input type="text" name="name" placeholder="Enter your name" required/>
<input type="text" name="email" placeholder="Enter your email" required/>
<input type="password" name="password" placeholder="Enter password" required/>
<input type="submit" value="Register"/>
</pre>
<%
String str = (String) request.getAttribute("message");
if(str!=null){
out.print(str);
}
%>
</form>
<a href="/login.jsp">Login</a>
</body>
</html>
\ No newline at end of file
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<!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=UTF-8">
<title>Welcome Page Title</title>
</head>
<body>
<h4>Welcome To Nepal</h4>
<s:bean name="test.Login" var="hello_bin">
<s:param name="message">Hello, this is bean tag!</s:param>
</s:bean>
<s:property value="message"/>
<p>Bean tage message property value is: <s:property value="hello_bin.message"/> </p>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</body>
</html>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundatio//DTD Struts Configuration 2.5//EN"
"http://struts.apache.org/dtds/struts-2.5.dtd">
<struts>
<constant name="struts.devMode" value="true"/>
<package name="test" extends="tiles-default" namespace="/">
<!--This is a comment: extends="struts-default" -->
<interceptors>
<interceptor-stack name="appDefault">
<interceptor-ref name="timer" />
<interceptor-ref name="logger" />
<interceptor-ref name="defaultStack" />
</interceptor-stack>
<interceptor name="upper" class="controllers.ValidatorInterceptor" />
</interceptors>
<default-interceptor-ref name="appDefault" />
<action name="index">
<result>/index.jsp</result>
</action>
<action name="login" class="test.LoginAction" method="execute">
<interceptor-ref name="timer"/>
<interceptor-ref name="appDefault"/>
<result name="SUCCESS">/welcome.jsp</result>
<result name="FAILURE">/login.jsp</result>
</action>
<action name="register" class="test.RegistrationAction">
<interceptor-ref name="upper" />
<result name="SUCCESS">/welcome.jsp</result>
</action>
</package>
</struts>
\ No newline at end of file
package contollers;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;
import com.opensymphony.xwork2.util.ValueStack;
public class ValidatorInterceptor implements Interceptor{
public void init() {}
public String intercept(ActionInvocation ai) throws Exception {
ValueStack stack = ai.getStack();
String str = stack.findString("name");
stack.set("name", str.toUpperCase());
return ai.invoke();
}
public void destroy() {}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundatio//DTD Struts Configuration 2.5//EN"
"http://struts.apache.org/dtds/struts-2.5.dtd">
<struts>
<constant name="struts.devMode" value="true"/>
<package name="test" extends="tiles-default" namespace="/">
<!--This is a comment: extends="struts-default" -->
<interceptors>
<interceptor-stack name="appDefault">
<interceptor-ref name="timer" />
<interceptor-ref name="logger" />
<interceptor-ref name="defaultStack" />
</interceptor-stack>
<interceptor name="upper" class="controllers.ValidatorInterceptor" />
</interceptors>
<default-interceptor-ref name="appDefault" />
<action name="index">
<result>/index.jsp</result>
</action>
<action name="login" class="test.LoginAction" method="execute">
<interceptor-ref name="timer"/>
<interceptor-ref name="appDefault"/>
<result name="SUCCESS">/welcome.jsp</result>
<result name="FAILURE">/login.jsp</result>
</action>
<action name="register" class="test.RegistrationAction">
<interceptor-ref name="upper" />
<result name="SUCCESS">/welcome.jsp</result>
</action>
</package>
</struts>
\ No newline at end of file
package test;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Types;
public class Admin {
public Connection connection() throws Exception {
Class.forName("com.mysql.jdbc.Driver");
return DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
}
public String getUser(String user_email, String user_pass) {
try {
CallableStatement cs = connection().prepareCall("{call getUser(?,?,?)}");
cs.setString(1, user_email);
cs.setString(2, user_pass);
cs.registerOutParameter(3, Types.VARCHAR);
cs.executeQuery();
return cs.getString(3);
}
catch(Exception e) {
return e.getMessage();
}
}
public String addUser(String user_name, String user_email, String user_pass) {
try {
System.out.println(user_name+" | "+user_email+" | "+user_pass);
CallableStatement cs = connection().prepareCall("{call addUser(?, ?, ?, ?)}");
cs.setString(1, user_name);
cs.setString(2, user_email);
cs.setString(3, user_pass);
cs.registerOutParameter(4, Types.VARCHAR);
cs.executeQuery();
return cs.getString(4);
}
catch(Exception e){
return e.getMessage();
}
}
}
package test;
public class LoginAction {
private String email, password, message;
private String test;
private int abc;
public String getTest() {
return test;
}
public void setTest(String test) {
this.test = test;
}
public int getAbc() {
return abc;
}
public void setAbc(int abc) {
this.abc = abc;
}
public Admin getAd() {
return ad;
}
public void setAd(Admin ad) {
this.ad = ad;
}
Admin ad = new Admin();
public String execute() throws Exception{
message = ad.getUser(email, password);
if(message.startsWith("Sorry")) return "FAILURE";
return "SUCCESS";
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
package test;
import com.opensymphony.*;
public class RegistrationAction {
private String name, email, password, message;
Admin ad = new Admin();
private String parameters; //testing for interceptors: accessing input parameters
public String execute() throws Exception{
try {
setMessage(ad.addUser(name, email, password));
System.out.println(getParameters());
}
catch(Exception e) {
return e.getMessage();
}
return "SUCCESS";
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getMessage() {
return message;
}
public void setMessage(String msg) {
message = msg;
}
public String getParameters() {
return parameters;
}
public void setParameters(String parameters) {
this.parameters = parameters;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment