>>using servlet,jsp
>>first register with username and password
>>after login with that username and password
>>wihtout database
>>tools::in ecalipse ide.
>>please help me
>>with database we need to create a table like username,password
>>after we will get like this connection=new conection("jdbc:driver:localhost/8080:"username","passwordd")
>>but without database how to save the registration details ,how to get that details into login page thats my quetion ..
>>i think need to use hashmap
>>also use web.xml
>> i tried to get the details and save the details from registration.jsp using servet....
What I have tried:
register.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>User Data</title>
</head>
<style>
div.ex {
text-align: right width:300px;
padding: 10px;
border: 5px solid grey;
margin: 0px
}
</style>
<body>
Registration Form
<form action="Registration" method="post">
Full Name | <input type="text" name="fullname" /> |
Email | <input type="text" name="email" /> |
Username | <input type="text" name="username" /> |
Password | <input type="hidden" name="password" /> |
<input type="submit" value="Registration" />
</form>
</body>
</html>
Register.java
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class UserDataServlet
*/
public class RegistrationController extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = 1L;
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String name = request.getParameter("fullname");
String Addr = request.getParameter("address");
String age = request.getParameter("age");
String Qual = request.getParameter("qual");
String Persent = request.getParameter("percent");
String Year = request.getParameter("yop");
if(name.isEmpty()||Addr.isEmpty()||age.isEmpty()||Qual.isEmpty()||Persent.isEmpty()||Year.isEmpty())
{
RequestDispatcher rd = request.getRequestDispatcher("registration.jsp");
out.println("
Please fill all the fields");
rd.include(request, response);
}
else
{
RequestDispatcher rd = request.getRequestDispatcher("home.jsp");
rd.forward(request, response);
}
}
}