<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>I found a solution, if anyone encounters the same problem. After looking through the source, It seems like opencms expects you to use CmsJspBean to modify SOME PARTS of the response object. Stephan was right, you can use the top response object to add headers like location or content-type, but you can only modify the status code by using CmsJspBean.setStatus, as the flex cache seems to ignore the status headers set on the response object. Alternatively, you can just set the cache property to 'bypass' on the jsp or folder that contains your jsp(s).</div><div><br></div><div>So to get at the methods on CmsJspBean, this was the tag I used:</div><div><br></div><div><div><jsp:useBean id="cms" class="org.opencms.jsp.CmsJspActionElement"></jsp:useBean></div><div><%</div><div> cms.init(pageContext, re<font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px;">quest, response);</span></font></div><div><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px;">%></span></font></div><div><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px;"><br></span></font></div></div><div><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px;">And then it is as easy as calling setStatus or setContentType:</span></font></div><div><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px;"><br></span></font></div><div><div><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px;"><%</span></font></div><div><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px;"> </span></font></span><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px;">cms.setStatus(301);</span></font></div><div><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px;"> cms.setContentType("text/javascript");</span></font></div><div><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px;">%></span></font></div><div><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px;"><br></span></font></div></div><div><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px;">If you need to add arbitrary headers into your response, like location, or content-type headers, use the top response object as suggested by Stephan:</span></font></div><div><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px; line-height: 15px; white-space: pre;"><span class="Apple-style-span" style="line-height: normal; white-space: normal;"><br></span></span></font></div><div><span class="Apple-style-span" style="line-height: 15px; white-space: pre; "><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px;"><%@page import="org.opencms.flex.*" %></span></font></span></div><div><span class="Apple-style-span" style="line-height: 15px; white-space: pre;"><%</span></div><span class="Apple-style-span" style="line-height: 15px; white-space: pre; "><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px;"><span class="Apple-tab-span" style="white-space:pre"> </span>HttpServletResponse topLevelResponse = CmsFlexController.getController(request).getTopResponse();
<span class="Apple-tab-span" style="white-space:pre"> </span>topLevelResponse.setHeader("Location", "<a href="http://www.google.com/">http://www.google.com/</a>" );</span></font></span><div><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px;"></span></font><span class="Apple-style-span" style="line-height: 15px; white-space: pre;"><span class="Apple-style-span" style="line-height: normal; white-space: normal; font-size: 12px; "> <span class="Apple-style-span" style="line-height: 15px; white-space: pre; ">topLevelResponse</span>.setHeader("Content-Type", "text/javascript");</span></span></div><div><span class="Apple-style-span" style="line-height: 15px; white-space: pre;"><span class="Apple-style-span" style="line-height: normal; white-space: normal; font-size: 12px; "></span>%></span></div><div><span class="Apple-style-span" style="line-height: 15px; white-space: pre;"><br></span></div><div><span class="Apple-style-span" style="line-height: 15px; white-space: pre;">So, to send a 301 redirect, use the setStatus method from CmsJspBean, and the setHeader method from the top response object. I didn't mention in my earlier post that I was trying to find a way to accomplish both of these tasks (for different pages).<br></span><div><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px;"><br></span></font></div><div><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px;">-Mike</span></font></div><br><div><div>On Jun 15, 2009, at 6:19 PM, Mike Dikan wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Sorry, just found the static CmsFlexController.getController(request) method to answer the first part of my last email.<div><br></div><div>As for the second part, I attempted this:</div><div><font class="Apple-style-span" face="Helvetica, monospace, Fixedsys"><br></font></div><div><span class="Apple-style-span" style="font-family: 'courier new', monospace, Fixedsys; font-size: 13px; line-height: 15px; white-space: pre; ">HttpServletResponse topLevelResponse = CmsFlexController.getController(request).getTopResponse();</span><br><div><br></div><div>But calls to modify the headers on topLevelResponse don't seem to be taking effect.</div><div><br></div><div>Any pointers?</div><div><br></div><div>-Mike</div><div><br><div><div>On Jun 15, 2009, at 5:01 PM, Stephan Hartmann wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Hi Mike,<br><br>the reason why your attempts for setting the content type by either <br>using the response object or the contentType attribute in the page <br>directive is that the JSP is usually embedded by using the include <br>dispatcher of the request. From within an included webapp resource <br>(either servlet or JSP or filter) there is no way to modify response <br>headers, as defined in the servlet spec.<br>For your case, it would be sufficent to set the cache property of your <br>JSP to "bypass" which will lead to a forward instead of an include, what <br>will give you control over your response headers as well. Note that you <br>will lose flex cache functionality with that property set.<br>Another way to set response headers from an included JSP would be to get <br>hold of the top response object through the CmsFlexController object of <br>your request.<br><br>Regards,<br>Stephan<br><br>Mike Dikan schrieb:<br><blockquote type="cite">I have need for a jsp that spits out dynamic javascript called <br></blockquote><blockquote type="cite">something like javascript_dynamic_variable_init.jsp. In opencms, if <br></blockquote><blockquote type="cite">you have a file on the vfs that has extension .js, the content-type <br></blockquote><blockquote type="cite">header that is returned is of type 'application/x-javascript', and if <br></blockquote><blockquote type="cite">you have a file that ends in extension .jsp, the content-type header <br></blockquote><blockquote type="cite">is 'text/html'. I need to change the content-type header returned for <br></blockquote><blockquote type="cite">a file ending in .jsp to the .js header, but any attempts to do so <br></blockquote><blockquote type="cite">either by using the <%@page contentType="" %> tag, or operating on the <br></blockquote><blockquote type="cite">response directly is clobbered by opencms. Does anyone know how to do <br></blockquote><blockquote type="cite">this in opencms 7.0.5?<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">And to head off any questions, i can't rename the file to .js, because <br></blockquote><blockquote type="cite">the file needs to be brought in as a jsp opencms 'type' via the <br></blockquote><blockquote type="cite">synchronize functionality, which will only create types based on file <br></blockquote><blockquote type="cite">extensions, as far as I know.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Thanks!<br></blockquote><blockquote type="cite">-Mike<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">_______________________________________________<br></blockquote><blockquote type="cite">This mail is sent to you from the opencms-dev mailing list<br></blockquote><blockquote type="cite">To change your list options, or to unsubscribe from the list, please visit<br></blockquote><blockquote type="cite"><a href="http://lists.opencms.org/mailman/listinfo/opencms-dev">http://lists.opencms.org/mailman/listinfo/opencms-dev</a><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><br><br>_______________________________________________<br>This mail is sent to you from the opencms-dev mailing list<br>To change your list options, or to unsubscribe from the list, please visit<br><a href="http://lists.opencms.org/mailman/listinfo/opencms-dev">http://lists.opencms.org/mailman/listinfo/opencms-dev</a><br></div></blockquote></div><br></div></div></div></blockquote></div><br></div></body></html>