In trying to get parameters from the request in a JSP, and for some reason we can't use servlets.
I want to emulate that servlet behavior (doPost, doGet, doPut, etc) in a JSP page, we have a lot of them. Something like:
JSP File:
<%
new SomeClass(request, response).doRequest();
%>
< !--HTML-->
I know i can get the request method with request.getMethod()
, the GET parameters parsing request.getQueryString()
, and the body parsing the data in request.getReader()
.
But the body looks like this when submitting from a form
------WebKitFormBoundaryklIJzgCDUQ00bFB8 Content-Disposition: form-data; name="a" 123 ------WebKitFormBoundaryklIJzgCDUQ00bFB8 Content-Disposition: form-data; name="b" 456 ------WebKitFormBoundaryklIJzgCDUQ00bFB8 Content-Disposition: form-data; name="c"; filename="text.txt" Content-Type: text/plain Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris sed erat justo. Vestibulum id dui felis. Donec sagittis, nibh sit amet interdum dignissim, magna velit pulvinar odio, ut ornare dui nunc et quam. Sed vel lorem vestibulum, semper libero a, aliquet nunc. Praesent urna tortor, euismod nec dolor hendrerit, scelerisque vehicula nisl. Nunc a interdum mi, sed rhoncus elit. Sed nec lacus ultrices, dictum tellus sed, aliquam arcu. In pretium imperdiet dui, et rutrum ipsum commodo sit amet. Aliquam cursus metus ac imperdiet aliquam. ------WebKitFormBoundaryklIJzgCDUQ00bFB8--
So it won't be easy to parse.
Then in that class i'll have both the GET parameters and body parameters separately, the request method and files maybe.
Is there an utility, class, framework that can do this parse from the request object, or any advice you can give me.
I'm not against using servlets, but we have a lot of JSP files already created, and we will have to specify a servlet path for the each one, like /posts