
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to read form data using JSP via POST Method?
Below is the main.jsp JSP program to handle the input given by web browser using the GET or the POST methods.
Infact there is no change in the above JSP because the only way of passing parameters is changed and no binary data is being passed to the JSP program. File handling related concepts will be explained in a separate chapter where we need to read the binary data stream.
<html> <head> <title>Using GET and POST Method to Read Form Data</title> </head> <body> <center> <h1>Using POST Method to Read Form Data</h1> <ul> <li><p><b>First Name:</b> <%= request.getParameter("first_name")%> </p></li> <li><p><b>Last Name:</b> <%= request.getParameter("last_name")%> </p></li> </ul> <center> </body> </html>
Following is the content of the Hello.htm file −
<html> <body> <form action = "main.jsp" method = "POST"> First Name: <input type = "text" name = "first_name"> <br /> Last Name: <input type = "text" name = "last_name" /> <input type = "submit" value = "Submit" /> </form> </body> </html>
Let us now keep main.jsp and hello.htm in <Tomcat-installationdirectory>/webapps/ROOT directory. When you access http://localhost:8080/Hello.htm, you will receive the following output.
Try to enter the First and the Last Name and then click the submit button to see the result on your local machine where tomcat is running.
Based on the input provided, you will receive similar results as in the above examples.
- Related Questions & Answers
- How to read form data using JSP via GET Method?
- How to read form data using JSP?
- How to read all form parameters in JSP?
- How to post a form to PHP using Ajax .serialize() data?
- How to read a HTTP header using JSP?
- How to read cookies with JSP?
- How to read request parameters passed in URL using JSP?
- How to use POST method to send data in jQuery Ajax?
- How to post JSON object to Python CGI script via jQuery AJAX?
- How to upload multiple files via single form field via Python CGI script?
- How to pass check boxes data using JSP?
- How to post data to specific URL using WebClient in C#?
- Passing Information Using POST Method in Python
- How do I upload a file via AJAX without using HTML form?
- How to read data from *.CSV file using JavaScript?