I have tried this code, because I didn't use the showDocument(url,"_self")
method with "_self" parameter. and then it works for me. I mean the servlet
and the requested url have same session id, this is what I want
exactly...Thank you vey much...

Deniz...

----- Original Message -----
From: "Abhay" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, October 09, 2000 12:50 PM
Subject: Re: applet-servlet


> Hi !
> I think, since you are using doPost method, your code won't work, and will
> display 'not supported'. You should use doGet method along with doPost
> method in the servlet. Any static html page or servlets containing doGet()
> methods can be called by using Applet Context as,
>
>    AppletContext ac = getAppletContext();
>    try{
>            URL url=new URL("http://deniz:8080/servlet/Servlet_2");
>            ac.showDocument(url,"_self");
>    }catch(Exception e){showStatus("Error occured while contacting
> server...");}
>
>
> Abhay
>
> ----- Original Message -----
> From: DENIZ DEMIR <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Monday, October 09, 2000 2:26 PM
> Subject: applet-servlet
>
>
> > I have tried to invoke sendRedirect() in doPost method when the applet's
> > button is pushed, but it did not work. Here is the code:
> > Please help me...
> >
> > -------this is applet acctionPerformed code------------
> >
> >   void jButton1_actionPerformed(ActionEvent e) {
> >     System.out.println("Sending data...\n");
> >   try {
> >     URL url = new URL("http://localhost:8080/servlet/Servlet_1");
> >     URLConnection con = url.openConnection();
> >
> >
> >     con.setUseCaches(false);
> >     con.setDoOutput(true);
> >
> >     ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
> >     DataOutputStream out = new DataOutputStream(byteOut);
> >     out.writeUTF(txtField.getText());
> >     out.flush();
> >     byte[] buf = byteOut.toByteArray();
> >     con.setRequestProperty("Content-type", "application/octet-stream");
> >     con.setRequestProperty("Content-length", "" + buf.length );
> >
> >     DataOutputStream dataOut = new
> DataOutputStream(con.getOutputStream());
> >     dataOut.write(buf);
> >     dataOut.flush();
> >     dataOut.close();
> >   }catch(Exception ex) { ex.printStackTrace(); }
> >     System.out.println("Data was sent...");
> >   }
> >
> > ------and this is the servlet doPost code----------
> >
> >   public void doPost(HttpServletRequest request, HttpServletResponse
> > response) throws ServletException, IOException {
> >     response.setContentType("text/html");
> >     PrintWriter out = new PrintWriter (response.getOutputStream());
> >     out.println("<html>");
> >     out.println("<head><title>Servlet1</title></head>");
> >     out.println("<body>");
> >     out.println("The servlet has received a POST. This is the reply.");
> >     out.println("</body></html>");
> >
> >     DataInputStream in = new DataInputStream(request.getInputStream());
> >     String s = in.readUTF();
> >     in.close();
> >     out.println("<p>s: " + s);
> >     response.sendRedirect("http://deniz:8080/servlet/Servlet_2");
> >     out.flush();
> >     out.close();
> >   }
> >
> >
>
___________________________________________________________________________
> > To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> body
> > of the message "signoff SERVLET-INTEREST".
> >
> > Archives: http://archives.java.sun.com/archives/servlet-interest.html
> > Resources: http://java.sun.com/products/servlet/external-resources.html
> > LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
> >
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to