java - Retaining the submitted JSP form data -


I have a web form (JSP) that submits data to different applications hosted on different servers. After submitting the data, that application returns to the same JSP page. Now, I want to enter the data. What are the different approaches to keeping the submitted data in the web form? I do not like to store data in DB or any file.

PS: When the request is redirected to the same JSP page, I would like to maintain the submitted form. Therefore, the user does not need to re-enter the data. For example, data can be stored in session sessions or requests etc.

Best what you can do is your own servlet which is that java.net.URLConnection < With a little help of / code> in the background, requesting another request for external webpage. Finally post back to the result page within only one request, so that you can only access the request parameters. An implicit EL variable is $ {param} , which gives you access to request parameters such as map in which the parameter name is

then the following

  and 

More broadly the following servlet method

  Secure zero doPost (HttpServletRequest request, HttpServletResponse response) {string foo = request.getParameter ("foo") ; String bar = request.getParameter ("bar"); String url = "http://external.com/someapp"; String charset = "UTF-8"; String query = string.form ("fu =% s end time =% s", urlencoder.xcode (fu, charset), urlencoder.exode (bar, charset)); URL Connection Connection = New URL (url). OpenConnection (); Connection.setUseCaches (wrong); Connection.setDoOutput (true); // Trigger Post Connection.setRequestProperty ("Accept-Charset", Charset); Connection.setRequestProperty ("content-type", "app / x-www-form-urlxode; charset =" + charset); Try (OutputStream Vector Author = New OutputStream Water (connection.getOutputStream (), Charset)) {writer.write (query); } InputStream results = connection.getInputStream (); // Do something with the result here? Check whether he has returned the correct answer? // forward Request.getRequestDispatcher ("result.jsp") for JSP forwarded (request, response); }  

You should be able to use the input in the following type as result.jsp

  & lt; P & gt; Foo: & lt; C: Out value = "$ {param.foo}" /> & lt; / P & gt; & Lt; P & gt; Times: & lt; C: out value = "$ {param.bar}" /> gt; & Lt; / P & gt;  

Simple jsp: useBean and / or bad scriptlets are not required in that form.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -