How can I post XML data from JSP page to server?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
JSP is just a view technology providing a template to write HTML/CSS/JS in and the ability to interact with backend Java code using EL and taglibs like JSTL.
To send some information to the server side in HTML, you’d like to use a form with an input element and a submit button. E.g.
The webbrowser will send the input values as request parameter to the server side. You’d like to create a servlet wherein you just grab the request parameter as follows in the
doPost()method:Instead of a small input field, you can also use a textarea:
Grabbing the request parameter value in the servlet happens the same way.
If you actually wanted to upload a XML file, then you rather need an
<input type="file">:Obtaining the uploaded file is a whole story apart. The JSP/Servlet API prior to version 3.0 doesn’t offer builtin facilities for this. The file (and other kinds of fields) isn’t available as request parameter. You’d like to use Apache Commons FileUpload. You can find usage explanation and code examples in this answer.
See also: