| Код | package shop;
import Dao.ShopDao; import forms.EnterForm; import forms.RegistrationForm; import javax.servlet.http.HttpServletResponse; import java.io.IOException;
public class IdentificationManager { private ShopDao shopDao; private String Errormsg;
public void setShopDao(ShopDao shopDao) { this.shopDao = shopDao; }
public String getErrormsg() { return Errormsg; }
public void setErrormsg(String Errormsg) { this.Errormsg = Errormsg; }
public void registrationClient(RegistrationForm registrationForm, HttpServletResponse response) throws IOException { if (registrationForm.getCity().equals("") || registrationForm.getAddress().equals("") || registrationForm.getMail().equals("") || registrationForm.getLogin().equals("") || registrationForm.getPassword().equals("") || registrationForm.getConfirmpass().equals("")) { setErrormsg("Пожалуйста заполните все поля формы"); } else { shopDao.insertClient(registrationForm); response.sendRedirect("login.jsp?shop=ok"); } }
public void enterClient(EnterForm enterForm, HttpServletResponse response) throws IOException { if(!enterForm.getLogin().equals("") || !enterForm.getPassword().equals("")) { if(shopDao.clientFoundDb(enterForm) > 0){ response.sendRedirect("shop.jsp"); } else { } }
}
}
|
| Код | <%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page import="org.springframework.web.context.WebApplicationContext" %> <%@ page import="org.springframework.web.context.support.WebApplicationContextUtils" %> <%@ page import="shop.IdentificationManager" %> <%@ page import="tables.Clients" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<jsp:useBean id="registrationForm" class="forms.RegistrationForm" scope="request"> <jsp:setProperty name="registrationForm" property="*"/> </jsp:useBean>
<% WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(session.getServletContext()); IdentificationManager identificationManager = (IdentificationManager)ctx.getBean("identificationManager"); identificationManager.registrationClient(registrationForm,response); %>
<%=identificationManager.getErrormsg()%>
<html> <head><title>Welcome to shop</title></head> <body>
<form name="registrationForm" method="post"> .................................................................................
|
|