

{"id":81358,"date":"2020-08-31T09:00:20","date_gmt":"2020-08-31T03:30:20","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=81358"},"modified":"2021-08-25T13:47:38","modified_gmt":"2021-08-25T08:17:38","slug":"jsp-form-processing","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/jsp-form-processing\/","title":{"rendered":"JSP Form Processing using Get and Post Methods"},"content":{"rendered":"<p>This article discusses the form processing in JSP. It discusses the methods to send and process the information. It also discusses the GET and POST method of browsers and methods to get Parameters as well, along with their examples.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/JSP-Form-Processing.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-81417\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/JSP-Form-Processing.jpg\" alt=\"JSP Form Processing\" width=\"1200\" height=\"628\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/JSP-Form-Processing.jpg 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/JSP-Form-Processing-300x157.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/JSP-Form-Processing-1024x536.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/JSP-Form-Processing-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/JSP-Form-Processing-768x402.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/JSP-Form-Processing-520x272.jpg 520w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><\/p>\n<h2>JSP Form Processing<\/h2>\n<p>There are various situations where we are ought to send some important information from browser to web server; and then web server to backend program.<\/p>\n<p>For example, when we fill a form, the browser takes that data, sends it over the web server and ultimately processes it to the backend program. Thus reading and processing forms is very important.<\/p>\n<p>For sending this information, browser uses two methods:<\/p>\n<h3>1. GET method<\/h3>\n<p>This method is the default method used by the browser. This method sends the information attested to the requested URL separated by question mark sign (?). As this method sends data in an appended format, it is not recommended to use for sensitive information like passwords. However, this method has a limitation of characters i.e., 1024 bytes only in a request string.<\/p>\n<h3>2. POST method<\/h3>\n<p>This method of passing information is more reliable than the method above. This method is used for sensitive information. The POST method sends the information as a separate text message rather than appending the message in the URL. Thus it becomes more dependable. The information that comes from this method comes as standard input to the backend program.<br \/>\nForm Processing in JSP is handled using the following methods:<\/p>\n<p><strong>1. getParameter():<\/strong><br \/>\nThis method is used to get the value of the specified parameter.<br \/>\n<strong>2. getParameterValues():<\/strong><br \/>\nThis method returns multiple values of the specified parameter. In the case of form, this situation can arise when we use checkboxes.<br \/>\n<strong>3. getParameterNames()<\/strong><br \/>\nThis method returns the name of the parameters.<br \/>\n<strong>4. getInputStream()<\/strong><br \/>\nThis method reads the binary data sent by the client.<\/p>\n<p>Let\u2019s see how the forms are processed using these methods.<\/p>\n<h3>a. Using GET method to read data-with URL<\/h3>\n<p>For passing the information using URL, we need to call the program that will get the parameters using getParameter() method. Following is the program of get1.jsp that will be able to handle the input.<\/p>\n<p><strong>Example and Explanation:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">get1.jsp\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n  &lt;title&gt;GET using URL&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n \r\n&lt;body&gt;\r\n  &lt;h2&gt;--DataFlair--&lt;\/h2&gt;\r\n  &lt;h2&gt;GET Method to Read Form Data Using URL&lt;\/h2&gt;\r\n  &lt;ul&gt;\r\n            \t &lt;li&gt;&lt;p&gt;&lt;b&gt;First Name:&lt;\/b&gt;\r\n                            \t&lt;%= request.getParameter(\"first_name\")%&gt;\r\n            \t &lt;\/p&gt;&lt;\/li&gt;\r\n            \t &lt;li&gt;&lt;p&gt;&lt;b&gt;Last  Name:&lt;\/b&gt;\r\n                            \t&lt;%= request.getParameter(\"last_name\")%&gt;\r\n            \t &lt;\/p&gt;&lt;\/li&gt;\r\n  &lt;\/ul&gt;\r\n \r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>Go to the URL and type the URL as you are giving information through it.<br \/>\nhttp:\/\/localhost:8080\/FP\/get1.jsp?first_name=Kajal&#038;last_name=moryani<\/p>\n<p>These instructions will produce the following <strong>output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-81426\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP3.png\" alt=\"\" width=\"1366\" height=\"277\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP3.png 1366w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP3-300x61.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP3-1024x208.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP3-150x30.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP3-768x156.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP3-520x105.png 520w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h3>b. Using GET method to process data-using Form approach<\/h3>\n<p>In this approach, we make two files. One is our form that takes the data, and the other is our JSP file that reads and processes. Our form takes the first name and last name and calls the get1.jsp file as the form action.<br \/>\nExample and Explanation:<br \/>\nThe two codes are:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">get2.htm\r\n&lt;html&gt;\r\n &lt;body&gt;\r\n&lt;form action = \"get1.jsp\" method = \"GET\"&gt;\r\n     \tFirst Name: &lt;input type = \"text\" name = \"first_name\"&gt;\r\n     \t&lt;br \/&gt;\r\n     \tLast Name: &lt;input type = \"text\" name = \"last_name\" \/&gt;\r\n     \t&lt;input type = \"submit\" value = \"Submit\" \/&gt;\r\n  \t&lt;\/form&gt;\r\n  \t\r\n   &lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>When you run this file, you will get a form window. Fill in the credentials and click on the submit button.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-81427\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP4.png\" alt=\"\" width=\"1366\" height=\"165\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP4.png 1366w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP4-300x36.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP4-1024x124.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP4-150x18.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP4-768x93.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP4-520x63.png 520w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><\/a><\/p>\n<p>The form action will be passed to the jsp file to process the information. Here is the jsp code<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">get1.jsp\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n  &lt;title&gt;GET using form&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n \r\n&lt;body&gt;\r\n  &lt;h2&gt;--DataFlair--&lt;\/h2&gt;\r\n  &lt;h2&gt;GET Method to Read Form Data Using form&lt;\/h2&gt;\r\n  &lt;ul&gt;\r\n            \t &lt;li&gt;&lt;p&gt;&lt;b&gt;First Name:&lt;\/b&gt;\r\n                            \t&lt;%= request.getParameter(\"first_name\")%&gt;\r\n            \t &lt;\/p&gt;&lt;\/li&gt;\r\n            \t &lt;li&gt;&lt;p&gt;&lt;b&gt;Last  Name:&lt;\/b&gt;\r\n                            \t&lt;%= request.getParameter(\"last_name\")%&gt;\r\n            \t &lt;\/p&gt;&lt;\/li&gt;\r\n  &lt;\/ul&gt;\r\n \r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>Running these files we get the final output with our form data processed.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-81426\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP3.png\" alt=\"jsp get method\" width=\"1366\" height=\"277\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP3.png 1366w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP3-300x61.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP3-1024x208.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP3-150x30.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP3-768x156.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP3-520x105.png 520w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><\/a><\/p>\n<h3>c. Using POST method to process form data<\/h3>\n<p>POST method is similar in programming as the GET method. Using this method, the only thing that changes is that our data goes as a separate message rather than an appended string to URL.<br \/>\nLet\u2019s see the program. We make two files. One form file to take the information from the user and another one, a .jsp file to handle that form data.<\/p>\n<p><strong>Example and Explanation:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">post.htm\r\n&lt;html&gt;\r\n&lt;body&gt;\r\n \r\n  &lt;form action = \"post.jsp\" method = \"POST\"&gt;\r\n            \t First Name: &lt;input type = \"text\" name = \"first_name\"&gt;\r\n            \t &lt;br \/&gt;\r\n            \t Last Name: &lt;input type = \"text\" name = \"last_name\" \/&gt;\r\n            \t &lt;input type = \"submit\" value = \"Submit\" \/&gt;\r\n  &lt;\/form&gt;\r\n \r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>This html form file will take the input from the user and pass the action to the jsp file to handle the data. The code for .jsp file will be:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;html&gt;\r\n&lt;head&gt;\r\n  &lt;title&gt;Using POST Method&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n \r\n&lt;body&gt;\r\n \r\n  &lt;h1&gt;POST Method to Read Form Data&lt;\/h1&gt;\r\n \r\n \r\n            \t &lt;b&gt;First Name:&lt;\/b&gt;\r\n                            \t&lt;%= request.getParameter(\"first_name\")%&gt;\r\n            \t &lt;\/br&gt;\r\n            \t &lt;b&gt;Last  Name:&lt;\/b&gt;\r\n                            \t&lt;%= request.getParameter(\"last_name\")%&gt;\r\n            \t\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n \r\n<\/pre>\n<p>When this file runs using the POST method, we get the following <strong>output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP7.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-81425\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP7.png\" alt=\"jsp post method\" width=\"1366\" height=\"224\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP7.png 1366w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP7-300x49.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP7-1024x168.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP7-150x25.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP7-768x126.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP7-520x85.png 520w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><\/a><\/p>\n<h3>d. Giving Checkbox data as information and processing it.<\/h3>\n<p>Here we will read and process the checkbox items i.e. multiple values. We make a html file to input data and a jsp file to process that data. Following is the code.<\/p>\n<p><strong>Example and Explanation:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\"> subject.htm\r\n&lt;html&gt;\r\n&lt;head&gt;&lt;title&gt;Processing Checkbox data&lt;\/title&gt;&lt;\/head&gt;\r\n&lt;body&gt;\r\n \r\n&lt;form action = \"subject.jsp\" method = \"POST\" target = \"_blank\"&gt;\r\n &lt;input type = \"checkbox\" name = \"Maths\" checked = \"checked\" \/&gt; Maths&lt;\/br&gt;\r\n &lt;input type = \"checkbox\" name = \"Physics\"  \/&gt; Physics&lt;\/br&gt;\r\n &lt;input type = \"checkbox\" name = \"Chemistry\" \/&gt; Chemistry&lt;\/br&gt;\r\n &lt;input type = \"checkbox\" name = \"English\" checked = \"checked\" \/&gt; English&lt;\/br&gt;\r\n &lt;input type = \"checkbox\" name = \"Computers\" checked = \"checked\" \/&gt; Computers&lt;\/br&gt;\r\n &lt;input type = \"submit\" value = \"Select Subject\" \/&gt;\r\n&lt;\/form&gt;\r\n \r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>This code will produce the following <strong>output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-81418\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP1.png\" alt=\"\" width=\"1366\" height=\"236\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP1.png 1366w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP1-300x52.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP1-1024x177.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP1-150x26.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP1-768x133.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP1-520x90.png 520w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><\/a><\/p>\n<p>Further action will be taken by the jsp file to process this information. The code is:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\"> subject.jsp\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n  &lt;title&gt;Reading Checkbox Data&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n \r\n&lt;body&gt;\r\n  &lt;h1&gt;Reading Checkbox Data filled in form&lt;\/h1&gt;\r\n \r\n  &lt;ul&gt;\r\n            \t &lt;li&gt;&lt;p&gt;&lt;b&gt;Maths Checkbox:&lt;\/b&gt;\r\n                            \t&lt;%= request.getParameter(\"Maths\")%&gt;\r\n            \t &lt;\/p&gt;&lt;\/li&gt;\r\n            \t &lt;li&gt;&lt;p&gt;&lt;b&gt;Physics Checkbox:&lt;\/b&gt;\r\n                            \t&lt;%= request.getParameter(\"Physics\")%&gt;\r\n            \t &lt;\/p&gt;&lt;\/li&gt;\r\n            \t &lt;li&gt;&lt;p&gt;&lt;b&gt;Chemistry Checkbox :&lt;\/b&gt;\r\n                            \t&lt;%= request.getParameter(\"Chemistry\")%&gt;\r\n            \t &lt;\/p&gt;&lt;\/li&gt;\r\n            \t &lt;li&gt;&lt;p&gt;&lt;b&gt;English Checkbox:&lt;\/b&gt;\r\n                            \t&lt;%=request.getParameter(\"English\")%&gt;\r\n            \t &lt;\/p&gt;&lt;\/li&gt;\r\n            \t &lt;li&gt;&lt;p&gt;&lt;b&gt;Computers Checkbox:&lt;\/b&gt;\r\n                            \t&lt;%=request.getParameter(\"Computers\")%&gt;\r\n            \t &lt;\/p&gt;&lt;\/li&gt;\r\n  &lt;\/ul&gt;\r\n \r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>On running the jsp code, we will get the following <strong>output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP8.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-81422\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP8.png\" alt=\"\" width=\"1366\" height=\"336\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP8.png 1366w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP8-300x74.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP8-1024x252.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP8-150x37.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP8-768x189.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP8-520x128.png 520w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><\/a><\/p>\n<h3>e. Reading all Form Parameters<\/h3>\n<p>Using the Enumeration for all parameter names and parameter values, we can read the complete form data at once. For this, we call an enumeration of all parameter names. Implying while loop on parameter names we can simply get all values for all the parameters using hasmoreelements(). In this example, we have taken the output in a tabular format.<br \/>\nIn the example below we are having a form that asked for selecting subjects. Following is the code:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">subject.htm\r\n&lt;html&gt;\r\n&lt;head&gt;&lt;title&gt;Processing Checkbox data&lt;\/title&gt;&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;form action = \"main.jsp\" method = \"POST\" target = \"_blank\"&gt;\r\n &lt;input type = \"checkbox\" name = \"Maths\" checked = \"checked\" \/&gt; Maths&lt;\/br&gt;\r\n &lt;input type = \"checkbox\" name = \"Physics\"  \/&gt; Physics&lt;\/br&gt;\r\n &lt;input type = \"checkbox\" name = \"Chemistry\" \/&gt; Chemistry&lt;\/br&gt;\r\n &lt;input type = \"checkbox\" name = \"English\" checked = \"checked\" \/&gt; English&lt;\/br&gt;\r\n &lt;input type = \"checkbox\" name = \"Computers\" checked = \"checked\" \/&gt; Computers&lt;\/br&gt;\r\n &lt;input type = \"submit\" value = \"Select Subject\" \/&gt;\r\n&lt;\/form&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>After running this code, we get the following <strong>output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-81418\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP1.png\" alt=\"\" width=\"1366\" height=\"236\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP1.png 1366w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP1-300x52.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP1-1024x177.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP1-150x26.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP1-768x133.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP1-520x90.png 520w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><\/a><\/p>\n<p>When we run this html code and call main.jsp to process form data, we use following code:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">main.jsp\r\n&lt;%@ page import = \"java.io.*,java.util.*\" %&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n&lt;title&gt;Reading all parameters&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n &lt;h2&gt;Reading all parameters in the form&lt;\/h2&gt;\r\n &lt;table width = \"50%\" border = \"2\" &gt;\r\n &lt;tr&gt;\r\n  &lt;th&gt;Parameter Name&lt;\/th&gt;\r\n  &lt;th&gt;Parameter Value&lt;\/th&gt;\r\n &lt;\/tr&gt;\r\n &lt;%\r\n  Enumeration paramNames = request.getParameterNames();\r\n  while(paramNames.hasMoreElements())\r\n  {\r\n  String paramName = (String)paramNames.nextElement();\r\n  out.print(\"&lt;tr&gt;&lt;td&gt;\" + paramName + \"&lt;\/td&gt;\\n\");\r\n  String paramValue = request.getParameter(paramName);\r\n  out.println(\"&lt;td&gt; \" + paramValue + \"&lt;\/td&gt;&lt;\/tr&gt;\\n\");\r\n  }\r\n %&gt;\r\n \r\n &lt;\/table&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>Running this code we get the following <strong>output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP5.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-81424\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP5.png\" alt=\"\" width=\"1366\" height=\"268\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP5.png 1366w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP5-300x59.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP5-1024x201.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP5-150x29.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP5-768x151.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/FP5-520x102.png 520w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><\/a><\/p>\n<h2>Conclusion<\/h2>\n<p>In reference to this article, we discussed how the form data is taken and processed. This information is taken at the browser and sent to the webserver, which is finally given to the backend programming. We came to know about different methods and their applications as well.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This article discusses the form processing in JSP. It discusses the methods to send and process the information. It also discusses the GET and POST method of browsers and methods to get Parameters as&#46;&#46;&#46;<\/p>\n","protected":false},"author":10,"featured_media":81417,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22403],"tags":[23093],"class_list":["post-81358","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-jsp","tag-jsp-form-processing"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>JSP Form Processing using Get and Post Methods - DataFlair<\/title>\n<meta name=\"description\" content=\"Learn JSP Form processing - How form data is taken &amp; processed. This information is taken at the browser &amp; sent to webserver &amp; then to backend programming.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/jsp-form-processing\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JSP Form Processing using Get and Post Methods - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Learn JSP Form processing - How form data is taken &amp; processed. This information is taken at the browser &amp; sent to webserver &amp; then to backend programming.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/jsp-form-processing\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2020-08-31T03:30:20+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-08-25T08:17:38+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/JSP-Form-Processing.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"JSP Form Processing using Get and Post Methods - DataFlair","description":"Learn JSP Form processing - How form data is taken & processed. This information is taken at the browser & sent to webserver & then to backend programming.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/jsp-form-processing\/","og_locale":"en_US","og_type":"article","og_title":"JSP Form Processing using Get and Post Methods - DataFlair","og_description":"Learn JSP Form processing - How form data is taken & processed. This information is taken at the browser & sent to webserver & then to backend programming.","og_url":"https:\/\/data-flair.training\/blogs\/jsp-form-processing\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2020-08-31T03:30:20+00:00","article_modified_time":"2021-08-25T08:17:38+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/JSP-Form-Processing.jpg","type":"image\/jpeg"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/jsp-form-processing\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/jsp-form-processing\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/a90b082e16aa38d207212d22b0581f33"},"headline":"JSP Form Processing using Get and Post Methods","datePublished":"2020-08-31T03:30:20+00:00","dateModified":"2021-08-25T08:17:38+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/jsp-form-processing\/"},"wordCount":874,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/jsp-form-processing\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/JSP-Form-Processing.jpg","keywords":["JSP Form Processing"],"articleSection":["JSP Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/jsp-form-processing\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/jsp-form-processing\/","url":"https:\/\/data-flair.training\/blogs\/jsp-form-processing\/","name":"JSP Form Processing using Get and Post Methods - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/jsp-form-processing\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/jsp-form-processing\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/JSP-Form-Processing.jpg","datePublished":"2020-08-31T03:30:20+00:00","dateModified":"2021-08-25T08:17:38+00:00","description":"Learn JSP Form processing - How form data is taken & processed. This information is taken at the browser & sent to webserver & then to backend programming.","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/jsp-form-processing\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/jsp-form-processing\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/jsp-form-processing\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/JSP-Form-Processing.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/JSP-Form-Processing.jpg","width":1200,"height":628,"caption":"JSP Form Processing"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/jsp-form-processing\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"JSP Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/jsp\/"},{"@type":"ListItem","position":3,"name":"JSP Form Processing using Get and Post Methods"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/a90b082e16aa38d207212d22b0581f33","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/dd6de0d647a0185cd6faf264e4ba860b0d85d08d7070766f9cd41bea5bb0b227?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/dd6de0d647a0185cd6faf264e4ba860b0d85d08d7070766f9cd41bea5bb0b227?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/dd6de0d647a0185cd6faf264e4ba860b0d85d08d7070766f9cd41bea5bb0b227?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"The DataFlair Team is passionate about delivering top-notch tutorials and resources on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. With expertise in the tech industry, we simplify complex topics to help learners excel. Stay updated with our latest insights.","url":"https:\/\/data-flair.training\/blogs\/author\/dfadteam1\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/81358","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=81358"}],"version-history":[{"count":3,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/81358\/revisions"}],"predecessor-version":[{"id":81429,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/81358\/revisions\/81429"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/81417"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=81358"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=81358"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=81358"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}