• Post Reply Bookmark Topic Watch Topic
  • New Topic

Sending Request from a JSP page

 
Tina Coleman
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm a newbie at JSPs - can do the basics, but not much more. That said, here's my question:
Within a JSP page, I generate an XML document and have it available as a stream, which I then save for my own records off to a file. I need to send that XML document to another URL as an HTTP POST, and get back its HTTP response with its status code. How would I do this?
Options considered so far:
jsp:forward - but then I don't think I'd get back to my page, and I don't have a named parameter for the POST.
HTTPServletRequest - should I take the existing Request and revamp it, changing its URL to the target URL and somehow updating its info to be the XML file? (I have no idea how to do this - just considering it as an option)
 
Tim Holloway
Bartender
Posts: 18408
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually the hard part to me is the part about running a JSP and storing the output in a file, since normally a JSP is expected to return to the client.
What would probably work best is to have the client invoke a servlet, have the servlet build the XML. if you can do that by having the servlet invoke the JSP, so much the better. I suppose if nothing else, the servlet could do an internal URLRequest if nothing else (you can tell I need to RTFM here!). Then the servlet can post the XML via an HttpURLRequest, get the response code and return results.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!