• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

getResponse().setContentType("text/html") returning nullpointer exception

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am having trouble understanding the http response in my servlet. I am outputting html to screen but its not working in IE9, i looked at posts that had similar issues and they seem to suggest that the response content type should be set to html for the browser to interpret as html. So I have tried adding the setcontent line just before I stream the html as per below



However it seems that the getResponse() is null and I am getting a null pointer exception.

My question is how can I get this to be not null, is there a way of creating a new instance of this? There is no get or post methods in the servlet and not sure what the best way of getting my html to execute in IE9, all other browsers work fine.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You'll need to post more context than just those two lines of code. Where do they exist? In what class? In what method?

HttpServlet doesn't even define a getRepsonse() method, the response is passed to the handler method. So what's defining getResponse()?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic