Setting response header fron JSP

Hi
I would like to know how I can set "If-Modified-Since" header, so that when client refreshes the page again the server should send 304 (Not Modified) status to the client.
I was able to do this in servlets as follows,
{code}
class Servlt extends HttpServlet
    private long modifiedTime ;
    init()
        modifiedTime=System.timeMilliSeconds /1000*1000;
    //service method automatically calls getLastModified() for the conditional GET
    long getLastModified()
         return modifiedTime;
{code}
How I can achieve the same in JSP ?
Is this work for POST method?
Is refreshing the browser submits page with GET or POST ?
Please help me understanding these and the solution for the above using JSP.
Thanks in advance.{code}{code}{code}{code}{code}{code}{code}{code}{code}{code}{code}{code}{code}{code}{code}{code}{code}{code}{code}{code}{code}{code}{code}{code}{code}{code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Try to set "Last-Modified" response header via setDateHeader method.

Similar Messages

  • Setting response header without scriptlet

    Can I set a response header from JSP without using a scriptlet?
    With scriptlets I can do <%response.addHeader("name", "header")%>
    but is there also a JSTL tag or similar to do it? (Except for writing a custom tag myself)

    As far as i know JSTL is not designed for this, as it is designed to work as a view language in the mvc model.
    And since you handle requests and responses in a controller, I don't think there will be something for JSTL.

  • How to set response header in filter

    Hi,
    i want to set the response header in my security filter:
    private void setHeader() {
              FacesContext ctx = FacesContext.getCurrentInstance();
              if (ctx != null){
                   HttpServletResponse response = (HttpServletResponse)ctx.getExternalContext().getResponse();
                   response.setHeader("Pragma", "No-Cache");
                   response.setDateHeader("Expires",0);
                   response.setHeader("Cache-Control", "no-cache");
         }But ctx is always null? What am i doing wrong?
    Regards,
    barnti

    My understanding is you will not have Faces Context in a filter as you have not yet hit the faces lifecycle..
    Try the below to get the context.
         * (non-Javadoc)
         * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
        public void init(FilterConfig config) throws ServletException {
            setFilterCfg(config);
            setServletCtx(filterCfg.getServletContext());
         * Since your typical FacesContext.getCurrentInstance() will probably be
         * null due to the fact we have not hit the faces lifecycle yet, we must dup
         * some of the faces servlet code here to create a new current instance.
         * @param req
         * @param res
         * @return FacesContext which is fresh and virtually empty.
        protected FacesContext getFacesContext(ServletRequest req,
                ServletResponse res) {
            FacesContext facesContext = FacesContext.getCurrentInstance();
            if (facesContext != null) {
                return facesContext;
            //     Use the FactoryFinder to grab the Lifecycle object
            FacesContextFactory contextFactory = (FacesContextFactory) FactoryFinder
                    .getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
            LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder
                    .getFactory(FactoryFinder.LIFECYCLE_FACTORY);
            Lifecycle lifecycle = lifecycleFactory
                    .getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
            facesContext = contextFactory.getFacesContext(servletCtx, req, res,
                    lifecycle);
            ProtectedFacesContext.setFacesContextAsCurrentInstance(facesContext);
            return facesContext;
        }

  • Problem while setting response header in a filter

    Hi,
    I am intercepting response in a filter and trying to modify the response header, so that my subsequent class would get the header in request .
    Somehow i don't get the header in request. I don't know whats going wrong.
    I have few more filters other than the one in which i m modifying the response header.
    I change the response header before calling doFilter() method.
    Where am i going wrong ?

    The subsequent servlets and filters will get the same request that the first filter has. The passing to the next servlet is via a method call.

  • Setting content-type response header in BlazeDS

    Per this JIRA ticket, http://bugs.adobe.com/jira/browse/BLZ-428 , there is a suggested fix that includes setting the response content-type header to text/xml.
    The JIRA ticket name is
    pinging endpoint Returns a HTTP: Status 200 in ie8
    and the suggested fix is:
    The problem appears to be completely worked around by setting the following headers in our HTTP responses to Flash:
    Content-Type: text/xml; charset=UTF-8
    Cache-Control: no-cache
    What is the best way to do this is if using BlazeDS?
    I have tried to set the content-type within my data service desitnation class, by accessing the HttpServletResponse from the FlexContext class, however this does not work.  The content-type is still "application/x-amf" in the response.    I am assuming that BlazeDS sets the content-type sometime after my data service desination code is invoked.
    I have also tried to create a servlet filter and set the content-type header both before and after (in a finally block) my data service code is invoked, however neither of these approaches successfully ended up with a content-type of "text/xml" in the response.  My sense is that setting the content-type prior to the data service destination code is too early in the chain and setting in the finally block is too late (per the servlet spec you cannot set the content-type after getWriter() has been called).
    Any ideas are appreciated.
    Also any other ideas on how to solve the general IE8 issue described in the bug above are appreciated.
    I am using...
    BlazeDS version: 3.2.0.3978
    Flex SDK version: 3.4
    App Server: JBoss 4.5
    Java: 1.5_16
    Thanks,
    Kevin

    Hi,
    in the meantime I found a "known issue" that seems to be related to my problem but it is said to be fixed with 10.0 MP1 (and we use 10.3):
    ChangeRequest number: CR316761, CR318708
    Description. The servlet container used to append charset=ISO-8859-1 to the HTTP Header contentType in the response for non-JSP pages with any charset contents. This would result in improper display of multibyte characters.
    This problem has been resolved.
    Maybe the information is wrong. I will examine the CR and may apply them on our 10.3 environment but I would be glad if some oracle/bea engineer would intervene here.
    Cheers
    Thorsten

  • Response object in JSP Dyn page

    Hi SAP EP Gurus,
    I want to use response.setStatus() mehtod in jspdynpage but it is not working as expected. I am able to use other methods of response object like response.write().
    As per my knowledge if i set response.setStatus(200) is should send error to client but it is not seding error.
    It is working as same for both response.setStatus(200) and response.setStatus(500).
    Is there any special way to use response.setStatus() in portal? It is working as expected in normal jsp application.

    I tried but had no luck. Below is my JSPDYNPAGE code...
    <%@ page import="javax.servlet.http.HttpServletResponse" %>
    <%@ page import="com.sapportals.portal.prt.component.IPortalComponentRequest,com.sapportals.portal.prt.component.IPortalComponentResponse"%>
    <HTML>
         <head>
         </head>
         <body>
    <%
    IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();
    HttpServletResponse servletResponse = request.getServletResponse(true);esss
    servletResponse.setStatus(500);
    %>
              </body>
         </HTML>
    It is not working showing portal run time error

  • Setting response.setStatus

    Dear Sirs,
    How can I set the HTTP 1.1 Status Code, for example, for 413 ( Request Entity Too Large ) and then use it on the site.
    Thank you

    Sharif wrote:
    Dear nclow,
    Thanks a lot for your reply.
    I understand how to set it but how will I use it after I have set. For example something like
    if
    response.setStatus(HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE ) (may be if it is larger than say 100 character)
    then redirect to, say for example, tooLargeError.jsp.
    How will I do that please
    Thank youYour question makes no sense. The status code is a string sent in the headers of the response back to the client who made the request. Your code is generating the response. setStatus returns null. You cannot test the result of this because all you are doing is setting something.
    If you want to send a 413 code and a response that contains a pretty error message along with it, then YOU have to decide when a 413 is appropriate. Once you have determined in the code that you want to do this, you can set the header to 413, generate that error message however you want (e.g. hard-coded html, calling a method that returns an appropriate html response, calling another servlet, forwarding the processing jsp:forward, etc.) and return the response as normal.
    A better description of why you're sending a 413, when you would want to send it, and what you want to happen would elicit a better answer.

  • Setting Reponse Header in a portlet?

    I want to set the 'Content-Disposition' response-header field
    as 'attachment;"myfile.csv"'. So that user will be able to
    download the cotent as a .csv file.
    But the setHeader() of the response object doesn't seem to work
    in the portlet.
    How do I set the response header in a portlet?
    Thanks
    Sagar

    The subsequent servlets and filters will get the same request that the first filter has. The passing to the next servlet is via a method call.

  • JEditorPane - set http header

    hi
    how to set (or is it even possible) to set http header (in http request) in JEditorPane (to set referrer, user agent, etc.)
    thanks a lot

    Thanks Raja,
    I am not an ITS expert by any means. I need help to work out how use the information in OSS Note 494984 to solve my problem.
    The note seems to be about setting headers on all incoming requests to ITS.
    I need to set the content-type header on an outgoing response generated using a specific (XML) template.
    I did the BC440 course back in 2000 but after 2000 I never did another ITS project, focusing on Java and J2EE instead. So I am not sure how to apply what the OSS Note says. Do I need to assign the content type to a Business HTML parameter in the template? The documentation I have with SAP@Web Studio is not helpful.

  • ADF 10.1.3 : Problem while attaching cookies to response header

    Hello,
    Whenever i try to attach some cookie to the response header, i get following message on my top of my page
    *"DevelopersPageCache-Control: private Connection: Keep-Alive Keep-Alive: timeout=15, max=100
    Content-Type: text/html;charset=windows-1252 Content-Location:
    /DevelopersPage.jsp Content-Language: en-US Transfer-Encoding: chunked 6c 2710"*
    I dont want this message on my page. It was working fine before attaching any cookies. Can somebody suggest what do i need to do to avoid this message.
    Regards
    Lokesh

    James, what Venkat and Prashant are trying to do is something like this...
    1. If I connect to the DB using scott/tiger then in the preLogin method of the Toplink Session Listener class, the proxy user will connect using something like admin/welcome1 and in the database audit view, the name that shows up SHOULD BE that of admin and NOT of scott. This is called proxy authentication if it works fine.
    We developed the above scenario but in the audit logs, we still see scott instead of admin as the user who connected.
    2. This feature is available in the DB but our objective is to use it through TopLink
    Also see Toplink Proxy Authentication Not Working
    I hope I was able to explain the scenario clearly.
    Any help will be appreciated
    Regards,
    Amit

  • RFX Response Header : Fill Display Fields on Header Level

    Hi Gurus,
    There is a requirement at the client place to add the Display only field for RFx Response Header. Based on this required I have done the following activities.
    1. From 'Define Customer Display Fields on Header Level' in  SPRO i have appended the ZFIELD in the Response header structure.
    2. From 'Configure Control for Fields on Header Level' in SPRO i have made it visible true.
    3. From 'Fill Display Fields on Header Level' SPRO i have Enhanced the /SAPSRM/BD_PDO_FE_FILL_HEADER with implementation. And have given required filter criteria. In the implementation Class it has the return parameter as CS_HEADER_DATA. Where i could fill the my ZFIELD.
    The field is now displaying in the SRM portal. But the problem is that the ZFIELD is not being filled with any value, even though i supplied it.
    Is there any step that is missing to set the value?
    Regards,
    Hobs

    Hi,
    The main technique is to do your calculations in PAI of the screen for additional data B for the line item but as you said it is accessed only when you goto-> item -> additional dataB
    So you can do one more thing...do the calculation in PAI/PBO of the screen first and in userexit_save_document_prepare recalculate again and overwrite the old ones(or calculate for only the ones which are initial in the item) ..so if he goes to additional data B screen you give the user what he wants and if he doesn't userexit_save_document_prepare takes care of it
    user can go to additional dataB only a line item at a time so the chance that he takes all the line items one by one is less(for huge number of line items)..so you just calculate and overwrite the fields in the in the userexit if the field value is empty...or you can recalculate for all the cases and overwrite just in case there may be a problem....
    in the screen of the additional dataB
    Write logic for calculating the field values
    so in the userexit you write like
    if the fields are initial..
    calculate
    else
    *already calculated from the screen because user has viewed it
    endif.
    So you are safe that user can see what he wants and you can reassure that the value will be calculated and stored on the SAVE from user exit
    Please check,revert
    Reward if helpful
    Regards
    Byju

  • How to change response header from bex application?

    HI.
    I'd like to change language coding 'charset=gb2312' to 'charset=big5' and don't need to add neither 'big5' language package or unicode in server
    because the contents are input as 'big5' so I just need change charset incoding type.
    and even if I insert html code
    '<meta http-equiv="content-type" content="text/html; charset=big5">'
    very top of template.
    'big5' is not working because the response header is set as 'gb2312'.
    and as I said before don't need to install lanaguage package to server.
    just want to change response header
    but don't know how to do that.
    is there anyone who knows tip for this?
    thank you.

    Just to close this topic.
    I have reported a bug to Android project, because bottom-line they are responsible for the error - not SAP BEx.
    Anyone interested can see the bug report here:
    [http://code.google.com/p/android/issues/detail?id=24257]
    If you decide to look at the bug report, please mark it with a Star to bring focus on this problem.
    Best regards,
    Jacob

  • Payables Open Interface Import pass distribution set for header?

    Hi all,
    i'm using OEBS 12.1.3. I want to insert data into payables interface tables to create invoice via back-end. Is it possible to pass data for the DISTRIBUTION SET on header level? I searched in the table AP_INVOICES_INTERFACE but no such column founded. I'm able to pass info for the distribution on the line level...
    Any ideas?
    Thanks in advance,
    Bahchevanov.

    The before report trigger error does occur for n number of reasons...some of the solutions could be
    1. Setting up the debug/summarized params to Y or
    2. Two payables open interface import programs running at the same time and due to non-incompatibility setups, one of them is getting errored out. Try setting up incompatibility and this error will go away - the only problem with this approach is that if this program needs to run on frequent basis, then one will wait on other to complete and consume lot of time.
    3. Try to increase threads of concurrent manager under which this program runs for better resouce management.
    4. Check the normal AP side setups such as tax code definition, supplier site 'pay site flag' etc --Although before report error occurs at the place in rdf where these checks are yet not done but thought to share with you if it helps
    Thanks
    Girish

  • How to set the header variables in weblogic

    Hi,
    We have a following set up in our environment.
    We have weblogic and on the top of it we have apex listener deployed which redirects Oracle Apex.
    My Issue:
    How can we set up the header variables in weblogic once the user is authenticated against weblogic server.
    We are struck here, not knowing how to set the header variables in weblogic server. Its fairly straight forward for Oracle Access Manager or others..
    Thanks
    Ramesh P.

    maybe you are looking for the routing options
    http://docs.oracle.com/cd/E13159_01/osb/docs10gr3/userguide/modelingmessageflow.html#wp1125348

  • Setting the header of a Column group in a Advanced table dynamically

    Hi All,
    There is a requirement to set the Header of a column group in a Advanced table dynamically by fetching the values from a view attribute.
    Code :
    OAAdvancedTableBean spiderTbl1 ;
    Problem:
    It is not able to set the value for the header inspite of getting the handle of the bean.
    Analysis:
    the same piece of code works for
    1) Setting the text of the advanced table
    2) Setting the header of a column in a column group
    Please let me know if there is anything more that needs to be done for setting the prompt of a column group header.
    Thanks in advance!

    I have posted it without giving the complete code by mistake. Below is the code:
    OAAdvancedTableBean spiderTbl1 ;
    OASortableHeaderBean spiderHdr1;
    spiderTbl1 = (OAAdvancedTableBean)webBean.findChildRecursive("SpiderCatTbl1RN");
    if (spiderTbl1!=null){
    spiderHdr1= (OASortableHeaderBean)spiderTbl1.findChildRecursive("AnalogHdr");
    if (spiderHdr1!=null) {
    spiderHdr1.setAttributeValue(OAWebBeanConstants.PROMPT_ATTR,
    new OADataBoundValueViewObject(spiderHdr1,
    "SpiderCategory1",
    "ProjRegPVO1"));
    }

Maybe you are looking for