File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Ajax Frameworks and servlets question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Ajax Frameworks and servlets question" Watch "Ajax Frameworks and servlets question" New topic
Author

Ajax Frameworks and servlets question

Joel Bushart
Greenhorn

Joined: Aug 11, 2005
Posts: 11
I have a servlet returning dynamically generated xml which I am requesting via AJAX using the prototype library.

However I'm having a slight issue with multiple requests to the servlet (which is expected as I'm feeding values from a database to update some fields in the html) and it is appending the xml to the previous request.

For example:
First request returns
<code>
<root>
<item1 price="12.30" name="tie" />
<item2 price="1.50" name="shoelace" />
</root>

Second request returns
<root>
<item1 price="12.30" name="tie" />
<item2 price="1.50" name="shoelace" />
<item1 price="12.30" name="tie" />
<item2 price="1.50" name="shoelace" />
<item3 price="14.99" name="shirt" />
</root>
</code>


I'm curious if any frameworks are designed to specifically return xml properly from jdbc calls via servlets or should I just roll my own solution?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61199
    
  66

Actually, this is not to be expected and indicates that there is a coding error in your servlet if it is remembering previous values in subsequent calls.

I'm going to move this to the Servlets forum since it has little to do with Ajax, and everything to do with how you've coded your servlet.

Please supply your servlet code, and please use UBB code tags when posting it.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Joel Bushart
Greenhorn

Joined: Aug 11, 2005
Posts: 11
In attempting to issolate the bug so I could post a consise sample, I discovered the problem to be an arraylist that I allocated on object creation, but not in the doGet(). I moved it into the doGet() method and all is well.

example:
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61199
    
  66

Exactly what I expected to see. Instance variables in servlets are death.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Ajax Frameworks and servlets question