aspose file tools*
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
Author

Response from Servlet becomes null

zoheb siddiqui
Greenhorn

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
Marshal

Joined: Jan 10, 2002
Posts: 61658
    
  67

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] [Bear's FrontMan] [About Bear] [Books by Bear]
Nam Ha Minh
Ranch Hand

Joined: Oct 31, 2011
Posts: 498

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
Marshal

Joined: Jan 10, 2002
Posts: 61658
    
  67

But the point is that this:shows that he is not expecting XML, but HTML.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Response from Servlet becomes null