------------------Servlet File-----------------
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.*;
import javax.servlet.http.*;
public class Servlet1 extends HttpServlet {
String s="Naveed Ali";
private static final String CONTENT_TYPE = "text/html; charset=windows-1252";
public void init(ServletConfig config) throws ServletException {
super.init (config);
}
public void service(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
out.println("Hi this is testing");
out.println(s);
out.close();
}
}
JSP File
<%@ page
import = "java.io.*"
import = "java.lang.*"
import = "java.io.IOException"
import = "java.io.ObjectInputStream"
import = "java.io.ObjectOutputStream "
import = "java.net.MalformedURLException"
import = "java.net.URL"
import = "java.net.URLConnection"
%>
<%
URL yahoo = new URL("servlet url here");
URLConnection yc = yahoo.openConnection();
BufferedReader in = new BufferedReader(
new InputStreamReader(
yc.getInputStream ()));
String inputLine;
while ((inputLine = in.readLine()) != null)
out.print(inputLine+" ");
in.close();
%>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment