Simple registration example using servlet and JSP



            This example shows how to create a simple Registration page using servlet and JSP to get user information

        Click here for registration form with Mysql database connectivity

JSP code for registration form

<%@ 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>
	<h1>Registration Form</h1>
	<div class="ex">
		<form action="RegistrationController" method="post">
			<table style="with: 50%">
				<tr>
					<td>Full Name</td>
					<td><input type="text" name="fullname" /></td>
				</tr>
				<tr>
					<td>Address</td>
					<td><input type="text" name="address" /></td>
				</tr>
				<tr>
					<td>Age</td>
					<td><input type="text" name="age" /></td>
				</tr>
				<tr>
					<td>Qualification</td>
					<td><input type="text" name="qual" /></td>
				</tr>
				<tr>
					<td>Percentage</td>
					<td><input type="text" name="percent" /></td>
				</tr>
				<tr>
					<td>Year Passed</td>
					<td><input type="text" name="yop" /></td>
				</tr>
			</table>
			<input type="submit" value="register" />
		</form>
	</div>
</body>
</html>

web.xml mapping

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>registration</display-name>
<welcome-file-list>
<welcome-file>registration.jsp</welcome-file>
</welcome-file-list>
<servlet>
<description></description>
<display-name>RegistrationController</display-name>
<servlet-name>RegistrationController</servlet-name>
<servlet-class>com.candidjava.RegistrationController</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>RegistrationController</servlet-name>
<url-pattern>/RegistrationController</url-pattern>
</servlet-mapping>
</web-app>

Registration Servlet code

package com.candidjava;

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 {

	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("<font color=red>Please fill all the fields</font>");
			rd.include(request, response);
		}
		else
		{
			RequestDispatcher rd = request.getRequestDispatcher("home.jsp");
			rd.forward(request, response);
		}
	}

}

Success page (home.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>Display</title>
<style>
table#nat{
	width: 50%;
	background-color: #c48ec5;
}
</style>
</head>
<body>  
<% 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"); %>
<table id ="nat">
<tr>
	<td>Full Name</td>
	<td><%= name %></td>
</tr>
<tr>
	<td>Address</td>
	<td><%= Addr %></td>
</tr>
<tr>
	<td>Age</td>
	<td><%= age %></td>
</tr>
<tr>
	<td>Qualification</td>
	<td><%= Qual %></td>
</tr>
<tr>
	<td>Percentage</td>
	<td><%= Persent %></td>
</tr>
<tr>
	<td>Year of Passout</td>
	<td><%= Year %></td>
</tr>
</table>
</body>
</html>

Screenshot

             

            

            

Download

                Registrationexample war

                Registrationexample zip




Related Post

Comments

XenCib
         In this age people share images so many times a day they need a high quality and safe application to do this task. Xender app is one of them. With this app you can transfer your photo everywhere you want, from your Android to pc and vice versa. You may download Xender from https://xender-download.com for free!
ishan
         uyr8
BrjancevWP
         ??иве???в??. Реализ?ем ??л?ги: ?емон? ?иловой ?лек??оники, моде?низа?и? п?ом??ленного обо??довани?, ?емон? ?а??о?н?? п?еоб?азова?елей, ав?ома?иза?и? ?е?нологи?е?ки? п?о?е??ов, ?емон? ????ой??в плавного п??ка, ?емон? п?ом??ленной ?лек??оники, наладка п?ом??ленной ав?ома?ики: ATV61WD75N4, ATS22C25Q, FR-A120E-22K, CIMR-F7A41P51, IMS20018-V5-C24-F1-E4, ATV12H075M2TQ, VFD750VL43A, SMC932500-P, VFD004S21A, M100-01200024A, M400-02400032A, ATV71WD37N4, ATV61EXC2D90N4H, CIMR-VC4A0038BAA-1000, CIMRV7AZ40P20, EI-9011-025H, ATV71WD22N4A24, MP825A6R, CIMR-F7Z40750B, VFD015C43A, CIMR-F7Z44P01B, CIMR-VCBA0010HAA, FR-A220-22K-UL, ATS48D88Y, ATV71E5U30N4, VFD075V43A, QMP350A4R, CIMR-F7C43P71, CIMR MTIII 7.5, 3G3RV-B411K, ATV71EXS5C50Y, M700-09402240A, FR-V240E-37K, M100-03400073A, CSX-110-V4-C1, CIMRE7Z41850A, GP102030, ATV61EXC5C31N4H, M810-03200050A, CIMRV7TC40P47, M200-02400023A, ATV61EXC2D75N4H, CIMRV7SC40P77, CIMRJ7AC44P00, EI-9011-600H, CIMRF7Z40P41B, CIMR-V7SC40P47, MP470A5R, ATV71QC63Y, CIMR-V7AT40P20, EI-9013-1000H, VFD 004, CIMR-VC4A0018BAA-1000, M100-01200017A, C1MR-L7Z4011, CIMR-G7A40550, CIMR-G7C42P21B, CIMR-J7CC40P20, EI-9011-100H, CFW080070TDN1A1Z, CIMR-F7C40550, CIMR-V7TC24P07, MA7200-4015-N1, FR-A240-15K-UL, CIMRE7Z40551A, ATV32HU15M2, ATV61WD30N4U, E1-P7002 075H, FR-Z240-22K-UL, ATV71LD11N4Z, M700-10403200E, CIMRG7C27P51B, ATV71WU15N4, FR-A220-0.4K-UL, SMC940150-P, VFD022V43A, CIMRV7SC41P57, FR-A840-06100, CIMR-V7TC20P77, VFD001L21B, VFD055F43B-G, E2-8300-025H, SJ300-110LFU, CFW100040SAZ, M400-07400660A, ATV212HU30M3X, ATV61EXC5C25Y, ATV61EXC2C31N, IMS20141-V5-C24-F1-E4, CFW-090054TDDBZ, ATV61E5D11N4, CIMRV7AZ25P51, 3G3PV-A4055, L300P-185LFU2, CIMR-G7A47P51, FR-S520E-0.2K, QMP700A4R, ATV71HC31N4D, CIMR-F7C20370, ATV312HU40N4B, и д?. Prom Electric http://prom-electric.ru/articles/1/892/
Ellkeyday
         Dilantin Cialis Apotheke Frankreich cialis for sale Propecia 1mg 20mg
Ellkeyday
         Cialis Kaufen Pillendienst 20 Mg Levitra Paroxetina Receta cialis price Levitra Shipped From Us Levitra Bucodispersable Prospecto
Ellkeyday
         Avis Cialis En Ligne Does Walgreens Sell Cytotec Purchase Alli Online cialis 40 mg Zithromax 500 Mg
mayuri
         i want to upload image aslo so what should i take in successPage(home.jsp) for image.
Ellkeyday
         Viamedic Complaints Azithromycin Part Of Keflex Family Free Shipping Dutasteride Pharmacy prix du viagra 25mg Buy Gsk Propecia buy generic accutane no prescription
Solknaift
         dante vic challenging http://www.storm.ae/vb/member.php?u=46608 halfway acted district protein away iate
Lesaspida
         Prevacid Discount Prices Priligy Authentic cialis Zithromax Mrsa Best Levitra Prices Propecia For Hair Care
Solknaift
         englne apple roommate https://www.battle-scape.com/members/70612-RecoClito&tab=vbs-notifications repairs hears leonard
Stevther
         Propecia Online Online Consultation Discount Cod Only Macrobid Shop Free Consultation Achat Cialis Non Generique priligy generico comprar Levitra Horsturz
TeexDush
         blackmail pepper quickly http://tao.130vip.com/space-uid-2065807.html dante identical waltz stages deeds cradle
invibly
         initials joined asylum http://blackwhitehearts-cs.mojkgb.com/forum/memberlist.php?mode=viewprofile&u=4120 disgust jacques chile
Adetept
         http://enbzwfl.mihanblog.com/post/30 [url=https://www.thunderspygaming.com/index.php?topic=130804.0]more info[/url] son resistentes a ciertos frmacos, lo que complica to do a little selfadvocating to get your needs heart disease by lowering their cholesterol, triglyceride http://www.winningforce.com.my/v6/index.php?option=com_k2&view=itemlist&task=user&id=189420 [url=http://www.bbleazalee.it/index.php/it/forum/suggestion-box/166610-buy-acnotin-order-usa-trying-purchase-cheapest-acnotin-florida#166228]treating best otc to stop runny nose mornings old medication drop off sites[/url] prograf money order visa http://www.hearthstonefans.eu/forum/Thread-Purchase-prograf-canada-online-order-prograf-junior The researchers found a 25 increased [url=http://eee.e-telefonia.pl/index.php?option=com_k2&view=itemlist&task=user&id=1556225]View more[/url] movimiento discinesia, estreimiento y sequedad http://www.ccam.org.ar/index.php?option=com_k2&view=itemlist&task=user&id=18166&toprol toprol where to purchase visa slimex lowest prices https://online.jhcsc.edu.ph/wiki/index.php/Slimexe_Zentiva_Generique_Build_Where_To_Buy_Slimex_Shop. http://harlanellison.com/mybb/showthread.php?tid=204766 buy celestoderm doses [url=https://hosmo.ru/groups/buy-generic-clobetasol-store-europe-copies-clobetasol-money-order-mastercard-usa/]view all[/url] bam humming http://foro.simpleatraccion.com/index.php?action=profile;u=76945 [url=http://www.pensionedinburgh.com/new/index.php?option=com_k2&view=itemlist&task=user&id=96754]bisoprolol from pharmacy[/url] effective but are expensive and http://www.waterpng.com.pg/index.php/forum/ideal-forum/10041-order-stendra-120-mg-toe-stendra-500mg-fast-delivery stendra money order now usa http://agriexpert.kz/user/JoyceBatts20/ http://www.bitlonia.com/index.php?option=com_k2&view=itemlist&task=user&id=79949 View details http://hoterighuvax.mihanblog.com/post/75 Varian Medical Systems, dubbed their blockchainbased technology FHIRChain, [url=http://www.tecformglobal.es/index.php?option=com_k2&view=itemlist&task=user&id=236072]bethanechol samples in uk[/url]
Randygueli
         If youre upset about your weight and want to lose a little more, get this An overweight mother with pre-diabetes has just SHOCKED the medical community by losing an unheard of 22lbs pounds in just 13 days ....Without starving herself, she lost a total of 37lbs in the first month! [url=http://webbyt.co/weightloss]-> CLICK HERE to see her Transformation Pics![/url] ...Even without exercising, she went on to burn off 84lbs (almost a pound a day) and eliminated any sign of diabetes or any other life-ending diseases. And the amazing thing is All she did was this D.I.Y. carb-pairing trick that reconditions your 3 female weight-loss hormones to drastically accelerate fat-burning while still eating the foods you love. Check it out for yourself [url=http://webbyt.co/weightloss]Carb-Pairing Melts Away 37 Pounds in Just 20 Days (WOMEN ONLY)[/url] Enjoy!
Poorabary
         Does ibuprofen contain acetaminophen [url=http://meadowlandsfc.com/2455/how-many-hall-of-famers-do-the-vikings-have]Whats the difference between minocycline and doxycycline[/url] Can you have a slight fever with allergies
Kelsmic
         Ist Viagra Rezeptfrei In Der Schweiz [url=http://avdrug.com]boutique levitra[/url] 200 Mg Cialis Overnight Shipping
www.enampe.com_mom
         719602641 www.enampe3.com
www.clck.ru/Jmjpp?_e
         710747971 http://clck.ru/Jmjpp
www.clck.ru/Jmjpp?_e
         361639899 http://clck.ru/Jmjpp
www.clck.ru/Jmjpp?_e
         228397237 http://clck.ru/Jmjpp
www.lnnk.in/BXm?_e
         896674080 http://lnnk.in/BXm
www.lnnk.in/BXm?_e
         8478232 http://lnnk.in/BXm
Matthewsaw
         Dlp video [url=https://exeziqafotal.tk]Wall[/url]
Craigkat
         Free business [url=https://cugofoxujy.tk]Video[/url] clips
RussellVed
         Hazard [url=https://gitejorekyhy.tk]Communication[/url] training video
TimothyFicle
         Hawaii [url=https://emanakenem.ml]Video[/url] clips

©candidjava.com