• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

forwarding to an outside URL

 
Chicken Farmer ()
Posts: 1932
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Saloon Keeper
Posts: 27807
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ()
Posts: 1932
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
rubbery bacon. crispy tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic