Skip to main content

JSP Form Element


JSP Support all HTML Form Element Component means we will create JSP form using the HTML Form element.
Code for JSP Page of Form Element:-
<%--
    Document   : JspFormExample
    Created on : Jan 15, 2020, 3:09:43 AM
    Author     : Hp
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h1>Hello World!</h1>
        <form action="showdata.jsp"  method="post" name="frmreg">
         <label for="name"> Enter Name</label><input type="text" name="txtname" />
            <br>
            <br>
            <label for="pass"> Enter Password</label><input type="password" name="txtpass" />
            <br>
            <br>
            <label for="email"> Enter Email</label><input type="email" name="txtemail" />
            <br>
            <br>
            <label for="dob"> Enter DOB</label><input type="date" name="txtdate" />
            <br>
            <br>
             <label for="mobile"> Enter Mobile Number</label><input type="number" name="txtmobile" />
             <br>
             <br>
             <label for="Course"> Select Course</label><input type="radio" name="txtcourse" value="JAVA" />JAVA &nbsp;&nbsp;<input type="radio" name="txtcourse" value=".NET" />.NET
             <br>
             <br>
             <label for="Coursetype"> Select CourseType</label><input type="checkbox" name="course[]" value="Job Oriented" />Job Oriented &nbsp;&nbsp;<input type="checkbox" name="course[]" value="Certification" />Certification
             <br><br>
             <label for="Country"> Select Country</label>
             <select name="ddlcountry">
             <option value="INDIA">INDIA</option>
             <option value="USA">USA</option>
             <option value="UK">UK</option>
             <option value="CHINA">CHINA</option>
             </select>
           
             <br><br>
         
             <label for=""> Select State</label>
             <select name="state[]" multiple="true">
             <option value="MP">MADHYAPRADESH</option>
             <option value="UP">UP</option>
             <option value="UK">UK</option>
             <option value="HP">HP</option>
             </select>
             <br><br>
             Write your goal<br><br>
             <textarea name="txtcomment" rows="10" cols="30"></textarea> <br><br>
             <input type="submit" name="btnsubmit" value="Click" />
        </form>
     </html>
Code to Get data from JSP Form Component:-
<%--
    Document   : showdata
    Created on : Jan 15, 2020, 3:33:10 AM
    Author     : Hp
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h1>Name is <%=  request.getParameter("txtname")   %></h1>
         <h1>Password is <%=  request.getParameter("txtpass")   %></h1>
         <h1>Emailid is <%=  request.getParameter("txtemail")   %></h1>
         <h1>Mobile no  is <%=  request.getParameter("txtmobile")   %></h1>
         <h1>DOB is <%=  request.getParameter("txtdate")   %></h1>
         <h1>Course is <%=  request.getParameter("txtcourse")   %></h1>
         <h1>Course Type is <%
            String arr[] = request.getParameterValues("course[]");
            String d="";
            for(String s:arr)
            {
                d=d+s+" ";
            }
            out.print(d);
       
             %></h1>
             <h1>Country is <%=  request.getParameter("ddlcountry") %> </h1>
             <h1>Course Type is <%
            String arr1[] = request.getParameterValues("state[]");
            String d1="";
            for(String s:arr1)
            {
                d1=d1+s+" ";
            }
            out.print(d1);
       
             %></h1>
             <h1>Goal is <%=  request.getParameter("txtcomment") %> </h1>
    </body>
</html>

Comments

Popular posts from this blog

DSA in C# | Data Structure and Algorithm using C#

  DSA in C# |  Data Structure and Algorithm using C#: Lecture 1: Introduction to Data Structures and Algorithms (1 Hour) 1.1 What are Data Structures? Data Structures are ways to store and organize data so it can be used efficiently. Think of data structures as containers that hold data in a specific format. Types of Data Structures: Primitive Data Structures : These are basic structures built into the language. Example: int , float , char , bool in C#. Example : csharp int age = 25;  // 'age' stores an integer value. bool isStudent = true;  // 'isStudent' stores a boolean value. Non-Primitive Data Structures : These are more complex and are built using primitive types. They are divided into: Linear : Arrays, Lists, Queues, Stacks (data is arranged in a sequence). Non-Linear : Trees, Graphs (data is connected in more complex ways). Example : // Array is a simple linear data structure int[] number...

JSP Page design using Internal CSS

  JSP is used to design the user interface of an application, CSS is used to provide set of properties. Jsp provide proper page template to create user interface of dynamic web application. We can write CSS using three different ways 1)  inline CSS:-   we will write CSS tag under HTML elements <div style="width:200px; height:100px; background-color:green;"></div> 2)  Internal CSS:-  we will write CSS under <style> block. <style type="text/css"> #abc { width:200px;  height:100px;  background-color:green; } </style> <div id="abc"></div> 3) External CSS:-  we will write CSS to create a separate file and link it into HTML Web pages. create a separate file and named it style.css #abc { width:200px;  height:100px;  background-color:green; } go into Jsp page and link style.css <link href="style.css"  type="text/css" rel="stylesheet"   /> <div id="abc"> </div> Exam...

Conditional Statement in Python

It is used to solve condition-based problems using if and else block-level statement. it provides a separate block for  if statement, else statement, and elif statement . elif statement is similar to elseif statement of C, C++ and Java languages. Type of Conditional Statement:- 1) Simple if:- We can write a single if statement also in python, it will execute when the condition is true. for example, One real-world problem is here?? we want to display the salary of employees when the salary will be above 10000 otherwise not displayed. Syntax:- if(condition):    statements The solution to the above problem sal = int(input("Enter salary")) if sal>10000:     print("Salary is "+str(sal)) Q)  WAP to increase the salary of employees from 500 if entered salary will be less than 10000 otherwise the same salaries will be displayed. Solution:- x = int(input("enter salary")) if x<10000:     x=x+500 print(x)   Q) WAP to display th...