hi
one solution: make .jsp file and include output of a servlet in different server by making
<%
String line = "";
try {
URL url = new URL(
"http://127.0.0.1/servlets/test?name=Test");
BufferedReader in = new BufferedReader(
new InputStreamReader(url.openStream()));
line = in.readLine();
out.println( line );
in.close();
}catch (Exception e){
e.printStackTrace();
}
}
%>
<!-- here goes ur rest html code -->
The scheme presented by psvinayram above doesnot have to be in a JSP.
You could run the same code from a Java application.
Or is it that you want the output from a servlet to be presented inside an otherwise existing HTML page without any coding ? That would be interesting indeed !
yes the output of the servlet would go inside another html page on a remote server that does not suport java or anything. the only thing that I could think of so far was to link it in this way
<script src="http://server1.com/servlet/TestServet">
but I think that doesn't work I have play with that to see
Ok actualy this is what you do.
first you create a servlet but the output needs to be a javascript code
for example:
PrintWriter out = res.getWriter();
out.println( "function getOutput(){" );
out.println( "document.write('bla bla bla');" );
out.println( "}" );
out.close();
then you link a javascript file to this servlet. so the html would look like this:
<html>
<head>
<script src="url of the servlet"></script>
</head>
<body>
<script>
// a call to the java script function that your servlet outputs.
getOutput();
</script>
</body>
</html>
the result is that bla bla is printed in this page