简体   繁体   中英

jsp - Send a request to a Servlet, receive the response and open URL

I've been trying to solve this in many ways, and I've found this is the best approach i can get.

There is an existing web application, with several jsp's. Some of them include a button which at the moment calls for an Applet, going to be replaced. This jsp should send a base64-encoded XML file consisting of different parameters, captured both from the webpage AND from a properties file in a server.

I've thought of the following steps:

  1. First of all, the jsp sends a request to a servlet with the required user-introduced parameters.
  2. Second step: the servlet receives the information sent by the jsp and gets the extra information required from the properties file (which is obviously in the server side).
  3. The servlet creates the required XML file and encodes it in B64.
  4. Proceeds to send it back to the user's browser.
  5. Finally, the jsp should open a URL with the B64-encoded XML as a parameter.

The thing is: Is it possible for the jsp to send a request, receive a response, and finally, with that response, open a URL?

Thanks in advance!

I've been trying to solve this in many ways

Did you try with Ajax ? or Form Submit in JSP ?

The thing is: Is it possible for the jsp to send a request, receive a response, and finally, with that response, open a URL?

You can do that with Ajax call .
1.Have Jquery included in your jsp.
2.On click of button send ajax request to servlet
3.check the response on ajax success callback and open URL

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM