Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

forwarding to an outside URL

 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've written a web app that has a servlet that reads from a database a list of names and corresponding pager numbers, and forwards to a JSP that calls a custom tag to build an XML style JSP from the ResultSet (saved in the session), and includes that JSP in a frame on the calling JSP. Someone can then select a name, type in a message, and click submit, which sends a page to that person.
The paging mechanism is done via Verizon Wireless's webpage www.myairmail.com (my company has a contract with them). When the user clicks submit, it forwards the request to this website (via action=""). However, a confirmation page from Verizon is then displayed in this frame, which I'd like to instead put a personalized confirmation page.
Is there a way to forward from a servlet to an outside URL, or am I pretty much stuck with what I've got?
Thanks
Jason
 
Junilu Lacar
Bartender
Pie
Posts: 7771
62
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe you could use HttpURLConnection to submit the page and then parse the returned content for status messages then redirect to your own custom page.
Junilu
 
Junilu Lacar
Bartender
Pie
Posts: 7771
62
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would also look through the source code for test frameworks like HttpUnit for clues (I think its on SourceForge but there's definitely a link to it from http://www.JUnit.org ).
Junilu
 
Christopher Dixon
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may also find some tag libraries provide the functionality you're looking for. Check out the Jakarta Standard taglibs project, specifically the IO taglibor the Scrape taglib
Both encapsulate a call to another URL outside the web application quite nicely.
HTH,
Chris
 
Tim Holloway
Saloon Keeper
Posts: 18303
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think you are trying to forward - that would imply that the user is leaving your website. What you are actually trying to do is invoke someone else's webapp as a subroutine of your own web logic.
As Junilu said, the servlet can use HttpURLConnection for that, just like applets do (except that you don't have the "sandbox" restriction that applets have).
The only special considerations would be to allow for the extra time it takes to do a request to someone else's network (user's browser could time out) - and, of course, the fact that the external server might sometimes return an unexpected response.
 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What you said is right Tim, they have a CGI script that runs on the request, that's mainly what I was trying to get.
But I've decided to go another route. Since this webapp ties in with a bigger application that listens to a database for updates, I still have to come up with a way for that listener to page people when an event occurs. So I decided to dig into the javax.comm API and go that route instead, avoiding the whole Verizon webpage thing.
Thanks for the info and the links though, will come in very handy when I start learning the net API's.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic