• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

Register user problem in JSP and Servlet Project  RSS feed

 
Ranch Hand
Posts: 33
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to create a web application using JSP and Servlets only. In the web application users can register and then they can login. For this application I am using Oracle 10g express edition database.

The main problem with this application is that when the user fills up the form and clicks the Register me button, a blank screen is displayed. However, the data is inserted into the table.

Structure of users table
======================
Name Null? Type
--------------------------------- -------- ---------------

USERNAME VARCHAR2(5)
EMAIL VARCHAR2(30)
PASSWORD VARCHAR2(20)

home.jsp
---------
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Home Page</title>
</head>
<body>
<h2>Welcome to the Home Page</h2>
<%
request.getAttribute("user");
%>


You can choose any one option<br>
<a href="register.jsp">Create an account</a><br>
<a href="login.jsp">Login to your account</a>
</body>
</html>

register.jsp
------------
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Registration Page</title>
<script type="text/javascript">

</script>
</head>
<body>
<form action="RegisterServlet" method="POST">

Name<input type="text" name="username" id="uname" required /><br>
Email address<input type="email" name="email" id="emailAddr" required /><br>
Password<input type="password" name="password" id="p1" required /><br>
Re-enter password<input type="password" name="repassword" id="p2" required /><br>
<input type="submit" value="Register me" onClick="return checkFields()"/>

<a href="home.jsp">Go Back to Home</a>
</form>
</body>
</html>

RegisterServlet.java
----------------------


RegisterModel.java
---------------------


login.jsp
---------
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Login Page</title>
</head>
<body>
<form action="LoginServlet" method="post">
User name<input type="text" name="user" required/><br>
Password<input type="password" name="pass" required/><br>
<input type="submit" value="Login"/>
</form>
</body>
</html>

LoginServlet.java
-------------------


LoginModel.java
-----------------


logged.jsp
-----------
<%@page contentType="text/html" pageEncoding="UTF-8" import="com.model.LoginModel"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Logged in Page</title>
<script>
function preventBack(){window.history.forward();}
setTimeout("preventBack()", 0);
window.onunload=function(){null};
</script>
</head>
<body>
<!-- Logout <A> LINK -->
<a href="LogOutServlet">Logout</a>

<% LoginModel logModel=(LoginModel)session.getAttribute("user"); %>
User ${logModel.username}   logged in

<%-- Disabling this page caching in browser --%>
<%
response.setHeader("Cache-Control", "no-store");
response.setHeader("Pragma", "no-cache");
response.setHeader("Expires", "0");
%>
</body>
</html>

 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!