File tree Expand file tree Collapse file tree 2 files changed +63
-0
lines changed
online-store.web/src/main
java/com/itbulls/learnit/onlinestore/web/servlets Expand file tree Collapse file tree 2 files changed +63
-0
lines changed Original file line number Diff line number Diff line change 1+ package com .itbulls .learnit .onlinestore .web .servlets ;
2+
3+ import jakarta .servlet .http .HttpServlet ;
4+ import java .io .IOException ;
5+ import jakarta .servlet .ServletException ;
6+ import jakarta .servlet .annotation .WebServlet ;
7+ import jakarta .servlet .http .HttpServletRequest ;
8+ import jakarta .servlet .http .HttpServletResponse ;
9+
10+ @ WebServlet ("/form-demo" )
11+ public class FormDemoServlet extends HttpServlet {
12+
13+ protected void doPost (HttpServletRequest request , HttpServletResponse response ) throws ServletException , IOException {
14+ var writer = response .getWriter ();
15+ writer .println ("<p>Text Input: " + request .getParameter ("text" ) + "</p>" );
16+ writer .println ("<p>Password Input: " + request .getParameter ("password" ) + "</p>" );
17+ writer .println ("<p>Email Input: " + request .getParameter ("email" ) + "</p>" );
18+ writer .println ("<p>Date Input: " + request .getParameter ("date" ) + "</p>" );
19+ writer .println ("<p>Radio Input: " + request .getParameter ("radio" ) + "</p>" );
20+ writer .println ("<p>Checkbox Input: " + request .getParameter ("checkbox" ) + "</p>" );
21+ writer .println ("<p>Disabled Input: " + request .getParameter ("disabled" ) + "</p>" );
22+ writer .println ("<p>Readonly Input: " + request .getParameter ("readonly" ) + "</p>" );
23+ writer .println ("<p>Hidden Input: " + request .getParameter ("hidden" ) + "</p>" );
24+ writer .println ("<p>Car Input: " + request .getParameter ("car" ) + "</p>" );
25+
26+ }
27+
28+
29+ }
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html >
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < title > HTML Form Demo</ title >
6+ </ head >
7+ < body >
8+
9+ < form action ="form-demo " method ="POST ">
10+ < p > Text Input:< input type ="text " name ="text " size ="50 "
11+ maxlength ="10 " placeholder ="Enter your first name... "> </ p >
12+ < p > Password Input:< input type ="password " name ="password "> </ p >
13+ < p > Email Input:< input type ="email " name ="email "> </ p >
14+ < p > Date Input:< input type ="date " name ="date " required > </ p >
15+ < p > Radio Input:< input type ="radio " name ="radio " value ="radio1 "> </ p >
16+ < p > Radio Input:< input type ="radio " name ="radio " value ="radio2 "> </ p >
17+ < p > Checkbox Input:< input type ="checkbox " name ="checkbox " value ="checkbox " checked > </ p >
18+ < p > Disabled Input:< input type ="text " name ="disabled " value ="disabled " disabled > </ p >
19+ < p > Readonly Input:< input type ="text " name ="readonly " value ="readonly " readonly > </ p >
20+ < p > Hidden Input:< input type ="hidden " name ="hidden " value ="PRODUCT_ID_123 "> </ p >
21+ < p > Select Input:
22+ < select name ="car ">
23+ < option value ="bmw "> BMW</ option >
24+ < option value ="renault "> Renault</ option >
25+ < option value ="mercedes "> Mercedes</ option >
26+ < option value ="audi "> Audi</ option >
27+ </ select >
28+ </ p >
29+ < p > Reset Input:< input type ="reset " value ="RESET THE FORM "> </ p >
30+ < p > Submit Input:< input type ="submit " value ="Sign Up "> </ p >
31+ </ form >
32+
33+ </ body >
34+ </ html >
You can’t perform that action at this time.
0 commit comments