Servlet e Applet

1 resposta
M

Olá,

Tenho um applet no seguinte diretório:
c:jdk1.3.0_01in
Tenho um servlet no seguinte diretório:
c: omcatjakarta-tomcat-4.0.5webappsexamplesweb-infclasses

Quero que meu servlet execute esse applet, então coloquei a seguinte instrução:

public void doGet (HttpServletRequest req,
HttpServletResponse res)

throws ServletException, IOException

{
char aspa=’"’;

PrintWriter output;

res.setContentType(“text/html”);

output = res.getWriter();
StringBuffer buf = new StringBuffer();

buf.append("<html><head><title>

");

buf.append(“Titulo

“);

buf.append(”</title></head>

“);

buf.append(”<applet code=+aspa+nomeapplet.class+aspa width=750 height=250>

“);

buf.append(”</applet></html>”);

output.println(buf.toString());

output.close();

}

Quando executo esse servlet o browser não encontra meu applet (nomeapplet notinitied).
Se coloque o path (c:jdk1.3.0_01in) do applet dentro do servlet, ele não compila (dá erro de caracter ilegal).
Como faço pro servlet indicar o caminho do applet?

1 Resposta

Rafael_Steil

Da maneira que voce fez nao funciona mesmo. faca assim:

public void doGet &#40;HttpServletRequest req,
    HttpServletResponse res&#41; throws ServletException, IOException
&#123;
    PrintWriter output;
    res.setContentType&#40;"text/html"&#41;;
    output = res.getWriter&#40;&#41;;

    StringBuffer buf = new StringBuffer&#40;&#41;;
    buf.append&#40;"&lt;html&gt;&lt;head&gt;&lt;title&gt;"&#41;;
    buf.append&#40;"Titulo"&#41;;
    buf.append&#40;"&lt;/title&gt;&lt;/head&gt;"&#41;;
    buf.append&#40;"&lt;applet code='"+ nomeapplet +".class' width=750 height=250&gt;"&#41;;
    buf.append&#40;"&lt;/applet&gt;&lt;/html&gt;"&#41;;
    output.println&#40;buf.toString&#40;&#41;&#41;;
    output.close&#40;&#41;;
&#125;

[]'s
Rafael Steil

Criado 18 de outubro de 2002
Ultima resposta 18 de out. de 2002
Respostas 1
Participantes 2