Java Server Page

JSP Projects

JSP Project

adplus-dvertising
Write a program that Get the value from html page to JSP page
Previous Home Next
Save that as Registration.html

This page contain only input field.

<html>
  <head>
    <title>R4R Co In</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
      <H1 style="font-size: 20pt; font-style: italic;color: teal">
	  R4R Tech Soft! </H1>
      <H2 style="font-size: 15pt;color: purple">
	  Please enter your information,then press submit..</H2>
      <form method="post" action="">
      <BR>Enter your First name:
      <input type="text" name="firstName" size="20" value="" maxlength="10">
      <BR><BR>Enter your last name:
      <input type="text" name="lastName" size="20" value="" maxlength="10">
      <BR><BR>Chose your password
      <input type="password" name="password" size="20" value="" maxlength="10">
      <BR><BR>Phone/Mobile:
      <input type="text" name="phone" size="20" value="" maxlength="15">
      <BR><BR>Enter your Email-id:
      <input type="text" name="email" size="20" value="" maxlength="20">
      <BR><BR>
      &nbsp;&nbsp; <input type="submit" name="submit" value=" submit ">
      &nbsp; <input type="reset" name="reset" value="  reset  ">
      </form>
  </body>
</html>

Now import that HTML file( Registration.html) into JSP( login.jsp ) file and take its all parameter.

Save as a login.jsp
<!import pagkage %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.util.*;" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%--   save as a login.jsp this page import a
html file name as a Registration.html--%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; 
		charset=UTF-8">
        <title>R4R CO IN</title>
    </head>
    <body>
        <!import HTML file  >
        <%@include file="Registration.html" %> 
    <%
                //create a HTTP session
                HttpSession session1 = request.getSession(true);
                
                //Store all the parameter from Registration.html
                Enumeration e = request.getParameterNames();
                session1.setAttribute("At", e);
                //After store read and print all the parameter
                Enumeration ss = (Enumeration) session1.getAttribute("At");
                while (ss.hasMoreElements()) {
                String pname = (String) ss.nextElement();
                out.print(pname + ":" + request.getParameter(pname) + "<BR>");
                }
     %>
</body>
</html>
Output:
Previous Home Next