• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Response from Servlet becomes null

 
zoheb siddiqui
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65119
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Nam Ha Minh
Ranch Hand
Posts: 504
Eclipse IDE Firefox Browser Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, you should use:



if the content returned is text/xml
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65119
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But the point is that this:shows that he is not expecting XML, but HTML.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic