Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.help > #2863
| Newsgroups | comp.lang.java.help |
|---|---|
| Date | 2013-11-28 03:17 -0800 |
| References | <0000002c.65be143d@usw-ex0108-192.remarq.com> |
| Message-ID | <9a780f79-7c80-413b-9565-3af7c3a7a0f8@googlegroups.com> (permalink) |
| Subject | Re: simple Applet-Servlet communication (code provided) |
| From | g.balakrishnan.900@gmail.com |
On Saturday, March 17, 2001 3:11:06 PM UTC+5:30, valyuha wrote:
> Hi,
> I am trying to write a very simple communication between an
> applet and a servlet, based on an example I've seen on the Sun
> site. However, it is not working properly. I am running a JSDK2.1
> server, and I think the problem is in my applet, because I dont
> think I give it a proper URL to the servlet, although it seemed
> to me that I tried all the variations. The applet and servlet
> classes are in the same directory, if that helps. Anyway, if you
> guys could look at my code and tell me whats wrong, I would
> greatly appreciate it.
>
> import java.applet.*;
> import java.net.*;
> import java.io.*;
> import java.awt.*;
> public class TestApplet extends Applet
> {
> private String line;
>
> public void init () {
> try {
> URL url = new
> URL("http://localhost:8080/webpages/Web-inf/servlets/TestServlet?
> name=TestApplet");
> BufferedReader in = new BufferedReader(new
> InputStreamReader(url.openStream()));
> line = in.readLine();
> in.close();
> }
> catch (Exception e){e.printStackTrace();}
> }
>
> public void paint (Graphics g) {
> g.drawString (line, 20, 40);
> g.drawString("This is just applet drawing!", 20, 80);
> }
> }// testapplet
>
> import java.io.*;
> import java.util.*;
> import javax.servlet.http.*;
> import javax.servlet.*;
>
> public class TestServlet extends HttpServlet {
>
> public void doGet(HttpServletRequest req,
> HttpServletResponse res) throws ServletException,
> IOException
> {
> res.setContentType ("text/plain");
> PrintWriter out = res.getWriter();
> out.println ("Hello " + req.getParameter("name") + ", servlet
> talking!");
> out.close();
> }
> }// testservlet
>
>
> Thanks,
> Val.
Back to comp.lang.java.help | Previous | Next | Find similar | Unroll thread
Re: simple Applet-Servlet communication (code provided) g.balakrishnan.900@gmail.com - 2013-11-28 03:17 -0800
csiph-web