how jsp opens a web page ?

R

richardchaven

I want to build a simple JSP to act as a proxt to retrieve web page
(xml documents, actually) for an AJAX page (which cannot request
documents outside its own domain).

Please point me at some examples or give me a class name to start
with.

Thanks
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

richardchaven said:
I want to build a simple JSP to act as a proxt to retrieve web page
(xml documents, actually) for an AJAX page (which cannot request
documents outside its own domain).

Please point me at some examples or give me a class name to start
with.

Use a servlet instead of a JSP page.

Several JSP AJAX toolkits exist that comes with an
easy to extend servlet.

Arne
 
D

Daniel Pitts

I want to build a simple JSP to act as a proxt to retrieve web page
(xml documents, actually) for an AJAX page (which cannot request
documents outside its own domain).

Please point me at some examples or give me a class name to start
with.

Thanks

you would probably be better off getting a real proxy.

We use Resin for our webapps, and Apache as our webserver. Apache can
use ProxyPass to pass certain URLs to other sites.

Of course, there are plenty of other ways to do this :).


Hope this helped,
Daniel.
 
R

richardchaven

Use a servlet instead of a JSP page.

I want to be able to deploy a minimum of files (ideally one) without
configuring anything. If I can use a jsp to get data from a different
page, that will be the simpliest.

I've seens a reference to a custom tag library that allows one to, for
instance, embed a quote from a different site in a JSP, so it seems
like this is theoretically possible.

Any ideas ?
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

richardchaven said:
I want to be able to deploy a minimum of files (ideally one) without
configuring anything. If I can use a jsp to get data from a different
page, that will be the simpliest.

I've seens a reference to a custom tag library that allows one to, for
instance, embed a quote from a different site in a JSP, so it seems
like this is theoretically possible.

Any ideas ?

Try and take the body of servlet code below and copy
into a <% %> block in your JSP page.

But I warn you. You can easily get problems
with content type and blank lines when doing
what is servlet work in a JSP page.

Arne


================================================

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.net.*;

public class CopyServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
try {
URL url = new URL("http://www.foobar.dk/");
HttpURLConnection con = (HttpURLConnection)url.openConnection();
con.connect();
if(con.getResponseCode() == HttpURLConnection.HTTP_OK) {
InputStream is = con.getInputStream();
byte[] b = new byte[1000];
int n;
while((n = is.read(b)) >= 0) {
String s = new String(b,0,n);
response.getOutputStream().println(s);
}
is.close();
}
con.disconnect();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top