How to set the content type of a JSP

You can use a JSP to generate HTML or XML, … setting the content type of the JSP cannot be done in your servlet using request.setContentType() method, however. Instead, you must use the JSP content type directive. For example, to set the content type to text/xml, include the following line in your JSP.


<%@ page contentType="text/xml" %>

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

Gravatar
WordPress.com Logo

Please log in to WordPress.com to post a comment to your blog.

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.