File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Response from Servlet becomes null Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Response from Servlet becomes null" Watch "Response from Servlet becomes null" New topic

Response from Servlet becomes null

zoheb siddiqui

Joined: May 08, 2008
Posts: 11
hi i am developing a web application in struts 1.3 using netbeans . i have a jsp page in which i have 2 dropdowns one is for populating location and other is for floors on selection of location .respective floors are displayed . now i am facing a peculiar problem have made use of ajax and servlet to achieve this but when a request is send to the servlet its create a dropdown in html and write it in PrintWriter stream by using its object but when i check the response on the javascript function using alert it becomes blank and therefore second dropdown not populating with data i have been struggling with this problem since past few days but if i write the same code of servlet for populating the second drop down in a jsp and calling jsp file rather than calling a servlet it is showing data ,its working . my

My jsp

my servlet

what actually i am doing wrong i am not understanding
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63867

If you intend to return HTML, why are you setting the content type to XML?

And why aren't you using a library to do the Ajax? Few senior developers will write Ajax "by hand" like this.

[Asking smart questions] [About Bear] [Books by Bear]
Nam Ha Minh
Ranch Hand

Joined: Oct 31, 2011
Posts: 502

Hi, you should use:

if the content returned is text/xml

PM Me If You Want to get Urgent Help on Java Programming
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63867

But the point is that this:shows that he is not expecting XML, but HTML.
I agree. Here's the link:
subject: Response from Servlet becomes null
It's not a secret anymore!