File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes SAX parser servlet help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "SAX parser servlet help" Watch "SAX parser servlet help" New topic

SAX parser servlet help

Diego Tori

Joined: Nov 18, 2004
Posts: 3
It seems that Ant won't let me compile this file since it appears to be laden with errors. What this servlet does is that it prompts for a search term provided by the user in order to search within an RSS feed for headlines that contain the search term, and write them out in HTML. The error that I keep getting is "illegal start of expression" in the startElement method. Can someone please see if the syntax is correct as well as point out the mistakes that I have made? Thanks.

[ November 18, 2004: Message edited by: Diego Tori ]
[ November 18, 2004: Message edited by: Diego Tori ]
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040

Welcome to the ranch.

You code seems to involve a lot of stuff. Generally, its a good ide to seperate stuff and not put too much into one file. Here you have servlet code that seems to output HTML, which is good. But your attempt to stuff it with XML Parsing makes the code rather ugly and difficult to follow / debug.

If you agree that its difficult to debug, I would suggest that you seperate the parsing from the servlet code. Generally this is done inside a Java Bean class of some kind.

Also if you could tell us how familiar you are with Servlets / XML parsing, it would help us to point you in the right direction with some links.
Consider that and then lets see where we go...

- m
Diego Tori

Joined: Nov 18, 2004
Posts: 3
OK, it seems that I put a method in a method, and that's why it was laden with errors. I made some necessary changes to the code, but it's still throwing me some errors, possibly a syntax error. I just started learning how to write servlets a month ago, thus my knowledge is limited. How would I successfully integrate these classes into one servlet, a.k.a., the standard skeletal syntax for a servlet of this nature.

Here's some updated code:

[ November 19, 2004: Message edited by: Diego Tori ]
I agree. Here's the link:
subject: SAX parser servlet help
It's not a secret anymore!