How do I 'leave' a servlet to load a page on another domain ?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Mike_Sheen
Posted On:   Thursday, April 3, 2003 09:12 AM

I'm not quite sure how to phrase this but I'll try :) What I want to do is :- get user info via a JSP page JSP page posts request to Servlet Servlet processes data Servlet sends data to https server somewhere else I know I can do:- Get user info via a JSP page JSP page posts request to Servlet Servlet processes data Servlet sends data to another jsp page create form on new JSP with data in hidden fields user has to submit form on jsp to send data to another server. OK, from within a servlet I an use the    More>>


I'm not quite sure how to phrase this but I'll try :)
What I want to do is :-



  1. get user info via a JSP page
  2. JSP page posts request to Servlet
  3. Servlet processes data
  4. Servlet sends data to https server somewhere else

I know I can do:-



  1. Get user info via a JSP page
  2. JSP page posts request to Servlet
  3. Servlet processes data
  4. Servlet sends data to another jsp page
  5. create form on new JSP with data in hidden fields
  6. user has to submit form on jsp to send data to another server.

OK, from within a servlet I an use the following to get info from another url:-


			
url = new URL("https://some-secure-site.somewhere.else");
conn = (HttpsURLConnection)url.openConnection();
conn.setDoOutput(true);
byte[] bytes = queryString.getBytes();
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-length","" + bytes.length);

OutputStream out = conn.getOutputStream();
out.write(bytes);
out.flush();
out.close();
in = conn.getInputStream();


then display the returned html.

This works fine, except all the links in the 'new page are relative so they don't work because the page is displayed on my server.



However, what I really want to do is leave my server and open the page on the secure server. Is this possible?

   <<Less

Use BASE tag to fix relative links problem

Posted By:   Roger_Hand  
Posted On:   Thursday, April 3, 2003 09:49 AM

You can use the BASE tag to fix the relative links problem.
About | Sitemap | Contact