Trochę poprawiłem, ale nadal mogę z index.jsp przejsc na strone rejestracji no i chce zeby na stronie rejestracji zapisało mi dane do klasy osoba, takie jak imie nazwsiko miejscowosc data i wruciło na strone index.jsp, ale cos nie działa
Serwet.java
package bankowo;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Serwret extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
osoba a=new osoba(1234,"arek","zzz","13","siedlce");
String action = request.getParameter("action");
if (action.equalsIgnoreCase("rejestruj")){
a.setimie(request.getParameter("imie"));
a.setnazwisko(request.getParameter("nazwisko"));
a.setdata(request.getParameter("data"));
a.setmiejscowosc(request.getParameter("miejscowosc"));
getServletContext().getRequestDispatcher("/index.jsp").forward(request, response);
}
if (action.equalsIgnoreCase("loguj")){
if(request.getParameter("pin") == null){
getServletContext().getRequestDispatcher("/index.jsp").forward(request, response);
return;
}
String pin2 = request.getParameter("pin");
request.setAttribute("pin", pin2);
getServletContext().getRequestDispatcher("/logowanie.jsp").forward(request, response);
}
}
}
osoba.java
package bankowo;
public class osoba {
private int pin;
private String imie;
private String nazwisko;
private String data;
private String miejscowosc;
private int stan;
public osoba(int pin, String imie, String nazwisko, String data, String miejscowosc){
pin = this.pin;
imie = this.imie;
nazwisko = this.nazwisko;
data = this.data;
miejscowosc = this.miejscowosc;
}
public int getpin(){
return pin;
}
public String getimie(){
return imie;
}
public String getnazwisko(){
return nazwisko;
}
public String getdata(){
return data;
}
public String getmiejscowosc(){
return miejscowosc;
}
public int getstan(){
return stan;
}
public void setimie(String imie){
imie=this.imie;
}
public void setpin(int pin){
pin=this.pin;
}
public void setnazwisko(String nazwisko){
nazwisko=this.nazwisko;
}
public void setdata(String data){
data=this.data;
}
public void setmiejscowosc(String miejscowosc){
miejscowosc=this.miejscowosc;
}
public void setstan(int stan){
stan=this.stan;
}
}
index.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<TITLE>Bank Internetowy</TITLE>
<style type="text/css">
input[type="submit"]{
width: 100px;
color: red;
background-color: #111111;
border: 2px ridge red;
font-family: Komika Display;
font-size: 1em;
font-style: italic;
padding: 4px;
text-align: center; }
</style>
<style type="text/css">
input[type="text"]{
width: 100px;
color: black;
background-color: #98FB98;
border: 2px ridge darkgreen;
font-family: Verdana,sans-serif;
font-size: 1em;
font-style: italic;
padding: 4px;
text-align: center; }
</style>
</HEAD>
<BODY>
<font size="5"> <center>Mini Bank Internetowy</center></font>
<center>
<table border="0">
<br>
<FORM action="serwret" method="post" value="loguj">
<table border="0">
<tr>
<td>PIN:</td> <td><input type="text" name="pin"/></td>
</tr><tr>
<td colspan="2"><input type="submit" value="Zaloguj"/></FORM> <FORM action="rejestracja.jsp" method="post"><input type="submit" value="Zarejestruj"/></FORM></td>
</tr>
</table>
</center>
</table>
</BODY>
</HTML>
rejestracja.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!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=ISO-8859-1">
<title>Bank Internetowy</title>
<style type="text/css">
input[type="submit"]{
width: 100px;
color: red;
background-color: #111111;
border: 2px ridge red;
font-family: Komika Display;
font-size: 1em;
font-style: italic;
padding: 4px;
text-align: center; }
</style>
<style type="text/css">
input[type="text"]{
width: 100px;
color: black;
background-color: #98FB98;
border: 2px ridge darkgreen;
font-family: Verdana,sans-serif;
font-size: 1em;
font-style: italic;
padding: 4px;
text-align: center; }
</style>
</head>
<body>
<font size="5"> <center>Mini Bank Internetowy</center></font>
<table>
<tr>
<td>Imie: </td><td><input type="text" name="imie"/></td>
</tr>
<tr>
<td>Nazwisko: </td><td><input type="text" name="nazwisko"/></td>
</tr>
<tr>
<td>Data Urodzenia(dd/mm/rrrr): </td><td><input type="text" name="data"/></td>
</tr>
<tr>
<td>Miejscowosc: </td><td><input type="text" name="miejscowosc"/></td>
</tr>
<tr>
<td colspan="2"><FORM action="serwret" method="post" value="rejestruj"><input type="submit" value="Rejestruj"/></FORM></td>
</tr>
</table>
</body>
</html>
logowanie.jsp - jeszcze nie dokończone
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!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=ISO-8859-1">
<title>Bank Internetowy</title>
</head>
<body>
<font size="5"> <center>Mini Bank Internetowy</center></font>
<%
String pin2 = (String) request.getAttribute("pin");
String imie2 = (String) request.getAttribute("imie");
%>
<table>
<tr>
<td>Twój numer PIN:</td><td><%= pin2 %></td>
</tr>
<tr>
<td>Imie: </td><td><%= imie2 %></td>
</tr>
</table>
</body>
</html>
ktoś może pomóc???