sanjeev you are a star .... nice reply ... cheers guru -----Original Message----- From: Sanjeev Verma [mailto:[EMAIL PROTECTED]] Sent: 02 October 2002 15:09 To: [EMAIL PROTECTED] Subject: Re: Why the servlet is called two times
All inline. Regards Sanjeev -----Original Message----- From: bin cai [mailto:[EMAIL PROTECTED]] Sent: Tuesday, October 01, 2002 10:53 PM To: [EMAIL PROTECTED] Subject: Re: Why the servlet is called two times Hi, Sanjeev. Thanks a lot for your information. Let me clearify my problems. My main applet class is called StatApplet.java which is loaded in StatApplet.html. In this StatApplet.java, i create a JeditorPanel which is associate with the Servlet application called Section1Servlet.java via sumPane3 = new JEditorPane(new URL("http://root/servlet/Section1Servlet")); ********************************************************* My orignal query is still unanswered. Inside which lifecycle method of the your applet class are you doing this. What apparently is happening is that the method inside which this code is present is getting executed twice, which in turn results in the double execution of the servlet. So it is NOT a servlet related problem, but an Applet related problem. ********************************************************** So far it works well. In Section1Servlet, It invoke another servlet ShowSection.java by response.sendRedirect("/root/servlet/ShowSection1"). The problem now comes up. The ShowSection1 is invoked two times. after that, another servlet called ShowResult.java is invoked from ShowSection1.java. also it is invoked two times. what is more, all attributes bound to session are lost. ********************************************************* If you are using response.sendRedirect(URL_OF_THE_SERVLET) to chain servlets, you are doing the wrong thing because session attributes will not be available in this redirection. You should be using "RequestDispatcher" to be doing this so that session attributes are preserved. Of course, I am assuming that the servlet to which you are redirecting lies inside the same web application, else RequestDispatcher will not work. ********************************************************** I test these servlets without applet. They works well together. but when i embed these application in Applet.These problems come out. Also the tomcat becomes select tomcat and quit working. ********************************************************* Apparently you are working on Windows...and on the DOS prompt you have by mistake clicked, leading to a "FREEZE". Just press escape, your application will run. ********************************************************* the following are part of my attachement --- Sanjeev Verma <[EMAIL PROTECTED]> wrote: > It would help if you send relevant snippets of the > servlet and applet code. > Understanding from what you have said, it probably > looks like an applet > lifetime related problem, becoz' of which your > servlet gets invoked twice. > Inside which method of the Applet are you invoking > the servlet? Search for > your bug thier. > > Regards > Sanjeev > > -----Original Message----- > From: bin cai [mailto:[EMAIL PROTECTED]] > Sent: Friday, September 27, 2002 1:53 AM > To: [EMAIL PROTECTED] > Subject: Why the servlet is called two times > > > Hi, > currently i am encountering such problem. I guess it > is caused by applet and servlet. > I wrote two servlet calss called Retrieve.java and > showInfo.java. > In Retrieve.java, the sytem get information from > database and put the info in session. then invoke > ShowInfo.java by > response.sendRedirect("/root/servlet/ShowInfo"). > These > are simple and works well. > But when i embed these two servlets into java > applet, > it works rare. > in applet i have JeditorPanel which is associate > with > Retrieve.java. when applet is loaded, the > Retrieve.java is invoked and then invoke > ShowInfo.java. but the problem is the ShowInfo.java > is > invoked two times and the session is invalidated. > So the following sevelet class can't get parameters > from session. > I spend a lot of time trying to find the bug. just > failed.any one can help me out, really appreciate > bin > > ______________________________________________________________________ > Post your free ad now! http://personals.yahoo.ca > > ___________________________________________________________________________ > 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 > ______________________________________________________________________ Post your free ad now! http://personals.yahoo.ca ___________________________________________________________________________ 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