Hi,

I'm not exactly sure what your problem is but may I suggest a different 
architecture?  Why dont you have the "fileLoadedByUser" put in a queue - and 
in the init() start a worker thread that just processes the files one by one. 
 You could then accept someone's fax all the time.  Get an email address and 
confirm it was sent, or inform them of any error...

hope this helps.

cheers
dim

On Wed, 11 Jul 2001 18:43, Singh, Kamal Deep wrote:
> Hi,
>
>     I am making a simple servlet based solution in tomcat. I just have one
> servlet which internaly starts a thread. Now my requirement is that the
> second request to this thread doesn't starts a new thread util the earlier
> thread has done it's job. Everything is working fine besides that immediate
> second request to that servlet produces a "The page cannot be displayed"
> error. I tried debuging the service method of my servlet and in case of
> second respponse also the service method seems to be completed without any
> error but obviliouly there is something wrong somewhere. My environment is
> iis and tomcart.
>
> System.err.println("c1");
>         //Input and Output streams
>         is = req.getInputStream();
>         HTMLout = res.getOutputStream();
> System.err.println("c2");
>         String htmlResponseOpen;
>         String htmlResponseClose;
>
>         // Used to send response in the correct html format.
>         HtmlResponse listMainCss = new HtmlResponse();
> System.err.println("c3");
>         HTMLout.println("<HTML><HEAD><TITLE></TITLE></HEAD><BODY>");
>
>         // Create the desired format.
>         htmlResponseOpen = listMainCss.openMainCssStyle("List", "Fixed
> Income Sales Database - Send Fax ", 12, 4, 180, 128);
>         HTMLout.println(htmlResponseOpen);
> System.err.println("c4");
>         // Check whether any other process is already sending fax.
>         // If yes then ask the user to wait.
>         if (processFax.isAlive())
>         {
> System.err.println("c5");
>             //HTMLout.println("<BR><BR><center><h4>Another Process For
> Sending Fax Is Already Active</h4></center>");
>             HTMLout.println("<BR><center><h4>Try Later</h4></center>");
> System.err.println("c6");
>         }
>         else
>         {
>             // This method call will Upload the file from the
>             // user end to the web server.
> System.err.println("c7");
>             fileLoadedByUser = uploadFile(req, res);
> System.err.println("c8");
>             /**
>              * Hopefully at this point of time whole file uploaded by the
> user
>              * is in a String.
>              */
>
>             if ((fileLoadedByUser != null) ||
> (!fileLoadedByUser.equals("")))
>             {
>                 if ((fileLoadedByUser.indexOf("change1") != -1) &&
> (fileLoadedByUser.indexOf("change2") != -1))
>                 {
>                     processFax = null;
> System.err.println("c9");
>                     processFax = new ProcessFax(fileLoadedByUser,
> fileName); processFax.start();
>                     // Till now everything is fine and ProcessFax has been
>                     // started. Obviously at this point of time it cannot
> be // ensured that all the Faxes have been sent correctly.
> HTMLout.println("<BR><BR><center><h4>Started sending Faxes</h4></center>");
>
>                 }
>                 else
>                 {
> System.err.println("c10");
>                     HTMLout.println("<BR><BR><center><h2>RTF file is not in
> correct format.</h2></center>");
>                 }
>             }
>         }
>
> System.err.println("c11");
>         htmlResponseClose = listMainCss.closeMainCssStyle();
>         HTMLout.println(htmlResponseClose + "</BODY></HTML>");
> System.err.println("c12");
>         HTMLout.flush();
>         // Close the output stream.
>         is.close();
>         HTMLout.close();
>         htmlResponseOpen = null;
>         htmlResponseClose = null;
>         is = null;
>         HTMLout = null;

Reply via email to