First, you might get more help on your problem if you used a more
descriptive subject line rather than just "need help".
It would also be easier to help you if the stack trace of the exception was
provided.
Where are the variables out, forlog, NewsType, and NewsURL declared? If
they are class variables, you will have threading problems. Class
variables in a servlet are shared among all of the servlet threads handling
simultaneous requests. This can cause all sorts of odd errors. You should
make these variables local to the methods that use them.
-Richard
At 09:05 PM 9/10/01 +0800, you wrote:
>I have a ergent problem.
>
>In my servlet I new a class to parse the xml file. But I found that a
>unknown exception thrown at the sentence of new. it's ok when I test the
>servlet using main(). I am very confused of it.
>
>here is the code.
>
> public void doPost(HttpServletRequest request, HttpServletResponse
> response) throws ServletException, IOException {
>
> xmlParser xp=null;
> response.setContentType("text/html");
> out = new PrintWriter (response.getOutputStream());
> try{
> forlog=new logFile("newsfeeds.log");
> forlog.WriteLog(true,true,"doPost");
> NewsType=request.getParameter ("feedname");
> NewsURL=request.getParameter("xmldata");
> forlog.WriteLog (logFile.INPUT_LOG,NewsType);
> forlog.WriteLog (logFile.INPUT_LOG,NewsURL);
> forlog.EndLog();
> if(NewsType.equals("englishNews")) // THE PLACE EXCEPTIN THROWN
> xp=new xmlParser(xmlParser.NewsFeed,NewsURL);
> else if(NewsType.equals("englishGoalFlash"))
> xp=new xmlParser(xmlParser.MatchFeed,NewsURL);
> else if(NewsType.equals("englishMatchDetails"))
> xp=new xmlParser(xmlParser.MatchDetail,NewsURL);
> else postStr(true);
> sbis=new StringBufferInputStream(NewsURL);
> if((Node=xp.startParse (sbis))==null)
> postStr(false);
> }
> catch(Exception e)
> {
> forlog.WriteLog(e);
> }
> }
>
>The class to parse the xml is below
>public class xmlParser extends DefaultHandler
>{
> public xmlParser(int Nodetype,String surl)
> {
> Nodetype=type;
> }
>.......
>
>I have no idea what happened. Someone can help me?
>
>thank you very much. I am anxiously waiting for your suggestion.
>
>
>
___________________________________________________________________________
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