<p>Is there any way to do the equivalent of the following in a JSP without using scriptlet?</p>

<pre><code>&lt;% response.setContentType("text/plain");  %&gt;
</code></pre>

<p>I can't simply use</p>



<p>because I need to set the content-type in 2 places (each in a different branch of a ) and the JSP compiler will only allow one such directive.</p>

<p>Also, I can't write two separate JSPs and forward to one or the other in a servlet because the JSP is triggered by the container when an authentication failure occurs.</p>

<p>Cheers,
Don</p>

```
```
<%@ page language="java" contentType="text/plain" %>
```
```
Edit:
If you need to set the MIME type conditionally, you could use
```
```
<% 
if( branch condition ) { 
  response.setContentType("text/plain");
} else {
  response.setContentType("text/html"); 
}
%>
```
```
Obviously the above is a scriptlet which goes against the original question. Is there a particular reason for not wanting to use a scriptlet?
A better approach may be to perform the branch logic in a servlet and forward the request to a JSP which only handles the display. You may choose to use two separate JSPs, one for each content type, if the content itself differs.