• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

RequestDispatcher's forward method changes response's content type

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
i'm using jakarta-tomcat-4.0.1.
i made servlet code that looks like below,
response.setContentType("text/vnd.wap.wml");
RequestDispatcher rd = getServletContext().getRequestDispatcher("/wml1.jsp");
rd.forward(request, response);
and i requested to that servlet,
browser gets content type "text/html" instead of "text/vnd.wap.wml".
how did i get this unexpected result?
does forward method changed response object's content type?
if then, how can i set the content type correctly
without specifying the content type to jsp file(/wml1.jsp).
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
RequestDispatcher is used to chain servlets.
JSP pages use content type as text/html by default.
Using response.setContentType("text/vnd.wap.wml") in the JSP page may produce the desired result.
Napa
 
ht kim
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes you are right.
i just checked the java file interpreted from the jsp out. and there was setContentType method calling like this.
response.setContentType("text/html;charset=ISO-8859-1");
so setContentType before jsp executing was overwritten.
thanks napa.
 
Slime does not pay. Always keep your tiny ad dry.
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic