Caching JSP Response

Hi,
I am trying to get the response from the result of performing a pageContext.include("myPage.jsp") so that I can store it in cache to use the next time the page is loaded (for performance reasons). Does anyone know how to do this?
Much Thanks!!

Specifically, I want to get the String or byte array containing the page that will get sent back to the browser.

Similar Messages

  • JSP response into a Javascript code

    Suppose I have a form that I submit, and its action is set to a JSP page that returns a series of elements <option>, for example:
        <option>2005</option>
        <option>2006</option>
    Is it possible to GET that JSP response, inside the JavaScript code?
    Or should I better state, inside the JSP code, to return ONLY the numbers and then I get it on the JavaScript and use the .add() funtion to add the item to a <select> ?
    How do I save that response inside the JavaScript?
    For example, I am trying with this Javascript function that handles the changes on a drop-down list:
      function clickedOnPType(lista)
      document.form1.action = "searchAvailableYears.jsp?pType=" + txtPType;}
      document.form1.submit();
    }...And I am getting, in return, a series of <option> with the correct data...
    Thanking you in advance,
    MMS

    Oh hello... in one of my 1000 searches I found that
    post days ago and I was already trying with your
    code, but I was getting several errors like
    "undefined is null or not an object" (in IE),
    "xmlhttp.responseXML has no properties" (in
    Firefox).... Well one thing i wanted to discuss here is is wat properties does in general a XmlHttpRequest Object contains
    checkout the below interface which gives a clear understanding of the Object member properties.
    interface XMLHttpRequest {
      attribute EventListener   onreadystatechange;
      readonly attribute unsigned short  readyState;
      void  open(in DOMString method, in DOMString url);
      void  open(in DOMString method, in DOMString url, in boolean async);
      void  open(in DOMString method, in DOMString url, in boolean async, in DOMString user);
      void  open(in DOMString method, in DOMString url, in boolean async, in DOMString user, in DOMString password);
      void  setRequestHeader(in DOMString header, in DOMString value);
      void  send();
      void  send(in DOMString data);
      void  send(in Document data);
      void  abort();
      DOMString  getAllResponseHeaders();
      DOMString  getResponseHeader(in DOMString header);
      readonly attribute DOMString  responseText;
      readonly attribute Document   responseXML;
      readonly attribute unsigned short  status;
      readonly attribute DOMString  statusText;
    };therefore as you can see XmlHttpRequest.reponseXML returns a Document Object which has below set of properties.
    http://www.w3schools.com/dom/dom_document.asp
    http://www.javascriptkit.com/domref/documentproperties.shtml
    and as said earlier one can send AJAX response in three ways
    1).Plain text(with comma seperated values maybe): Which we can collect using XmlHttpRequest.responseText 2).XML: @ client side XmlHttpRequest.reponseXML create a DOM Object using which one can parse it get values
    of attributes and values of different tags and then update the view accordingly.
    3).JSON(Javascript Object Notation): It is a bit complicated thing to discuss at this moment
    however it uses the first property(Plain text) and then
    uses set of libraries to parse and update the view.
    checkout below links to understand it
    http://www.ibm.com/developerworks/library/j-ajax2/
    http://oss.metaparadigm.com/jsonrpc/
    >  function handleOnChange(ddl)
    >
    var ddlIndex = ddl.selectedIndex;
    var ddlText = ddl[ddlIndex].text;
    var frmSelect = document.forms["form1"];
    var frmSelectElem = frmSelect.elements;
    if(ddl.name="pType")
         txtYear = "";
    txtDay = "";
              txtTime = "";
              unblock(document.form1.year);
              block(document.form1.day);
              block(document.form1.time1);
         laProxLista = frmSelectElem["year"];
    if (ddl.options[ddl.selectedIndex].text !=
    txtPType = ddl.options[ddl.selectedIndex].text;
    else if(ddl.name="year")
         txtDay="";
         txtTime="";
              unblock(document.form1.day);
              block(document.form1.time1);
    laProxLista = frmSelectElem["day"];
    f (ddl.options[lista.selectedIndex].text != "---")
    txtYear = ddl.options[lista.selectedIndex].text;
    else if(ddl.name="day")
    {          txtTime = "";
              unblock(document.form1.time1);
    laProxLista = frmSelectElem["time1"];
    (ddl.options[ddl.selectedIndex].text != "---")
    txtDay = ddl.options[ddl.selectedIndex].text;
    else //time1
    laProxLista = null;
    if (ddl.options[ddl.selectedIndex].text != "---")
    txtTime1 = ddl.options[ddl.selectedIndex].text;
    if ( txtPType != "---")
    xmlhttp = null
    // code for initializing XmlHttpRequest
    Object On Browsers like Mozilla, etc.
    if (window.XMLHttpRequest){ 
    xmlhttp = new XMLHttpRequest()
    // code for initializing XmlHttpRequest
    Object On Browsers like IE
    else if (window.ActiveXObject) { 
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP")
    if (xmlhttp != null)
    if(ddl.name = "pType")
    // Setting the JSP/Servlet url to get
    XmlData
    url = "searchAvailableYears.jsp?pType="
    + txtPType;
                   else if(ddl.name = "year")
    url = "searchAvailableDOY.jsp?pType=" + txtPType
    PType + "&year=" + txtYear;
                   else(ddl.name = "day")
    url = "searchAvailableTimes.jsp?pType=" +
    e=" + txtPType + "&year=" + txtYear + "&day=" +
    txtDay;
    xmlhttp.onreadystatechange =
    handleHttpResponse;
    // Open the Request by passing Type of
    Request & CGI URL
    xmlhttp.open("GET",url,true);
    // Sending URL Encoded Data
    xmlhttp.send(null);
    else{
    // Only Broswers like IE 5.0,Mozilla & all other
    browser which support XML data Supports AJAX
    Technology
    // In the Below case it looks as if the
    browser is not compatiable
    alert("Your browser does not support
    XMLHTTP.")
    } //else
    } //if chosen
    //function
         //----------------------------Well as far as i can see i do not have any issues with it because your code looks
    preety much involved with your business logic but one thing i would like to reconfim
    here is the variable "xmlhttp" a global one.
    if no declare xmlhttp variable as a global variable.
    <script language="javascript">
    var xmlhttp;
    function handleOnChange(ddl){
    function verifyReadyState(obj){
    function handleHttpResponse() {
    </script>
    > function verifyReadyState(obj)
    if(obj.readyState == 4){
    if(obj.status == 200){
    if(obj.responseXML != null)
    return true;
    else
    return false;
    else{
    return false;
    } else return false;
    }I believe,this is preety much it.
    > function handleHttpResponse() [/b]
    if(verifyReadyState(xmlhttp) == true)
    //-----------HERE!! ---- I GET "UNDEFINED" IN THE
    DIALOG BOX
    //------- BELOW THE CODE LINE....---
    var response = xmlhttp.responseXML.responseText;
    alert(response);
    it is obvious that you would get Undefined here as responseText is not a property of Document Object or to be more specific to the Object what xmlhttp.responseXML returns.
    you might have to use that as alert(xmlhttp.responseText);
    and coming back to parsing the XML reponse you have got from the server we need to use
    var response = xmlhttp.responseXML.documentElement; property for it...
    and if you put as a alert message it has to give you an Output like"Object"
    alert(response);
    if that doesn't the browser version which you are using may not support XML properly.
    var response = xmlhttp.responseXML.documentElement;
    removeItems(laProxLista);
    var x = response.getElementsByTagName("option")
      var val
      var tex
      var newOption
                  for(var i = 0;i < x.length; i++){
                     newOption = document.createElement("OPTION")
                     var er
                     // Checking for the tag which holds the value of the Drop-Down combo element
                     val = x.getElementsByTagName("value")
    try{
    // Assigning the value to a Drop-Down Set Element
    newOption.value = val[0].firstChild.data
    } catch(er){
    // Checking for the tag which holds the Text of the Drop-Down combo element
    tex = x[i].getElementsByTagName("text")
    try{
    // Assigning the Text to a Drop-Down Set Element
    newOption.text = tex[0].firstChild.data
    } catch(er){
    // Adding the Set Element to the Drop-Down
    laProxList.add(newOption);
    here i'm assuming that i'm sending a xml reponse of format something below.
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <drop-down>
       <option>
            <value>1</value>
            <text>label1</text>
       </option>
       <option>
            <value>2</value>
            <text>label2</text>
       </option>
       <option>
            <value>3</value>
            <text>label3</text>
       </option>
    </drop-down>and i'm trying to update both option's value and label which would be something like
    <select >
    <option value="1">label1</option>
    <option value="2">label2</option>
    <option value="3">label3</option>
    <option value="4">label4</option>
    </select>else where if you are interested in getting a format like the one below
    <select >
    <option>label1</option>
    <option>label2</option>
    <option>label3</option>
    <option>label4</option>
    </select> try the below snippet
    var response = xmlhttp.responseXML.getElementsByTagName("text");
    var length = response.length;
    var newOption
    for(var i =0 ; i < length;i++){
       newOption = this.document.createElement("OPTION");
       newOption.text = response.childNodes[0].nodeValue;
    // or newOption.text = response[i].firstChild.data
    laProxList.add(newOption);
    Another thing...
    I have tried to set the content type inside the JSP
    to
    response.setContentType("text/html");
    AND to
    response.setContentType("text/xml");
    but none of the above is getting me results......use of response.setContentType("text/xml"); is more appropriate here.. as you are outputting XML or a plain text here...
    make sure you set the reponse headers in the below fashoin while outputting the results....
    response.setContentType("text/xml");
    response.setHeader("Pragma", "no-cache");
    response.setHeader("Cache-Control", "no-cache");
    response.setDateHeader("Expires", 1);
    response.setDateHeader("max-age", 0); and if you are serious about implementing AJAX i would advice you start learn basics of XmlHttpRequest Object and more about DOM parsing is being implemented using javascript.
    http://www.w3.org/TR/XMLHttpRequest/#xmlhttprequest0
    http://www.jibbering.com/2002/4/httprequest.html
    http://java.sun.com/developer/technicalArticles/J2EE/AJAX/
    http://developer.apple.com/internet/webcontent/xmlhttpreq.html
    http://www.javascriptkit.com/domref/documentproperties.shtml
    and then go about trying different means of achieving them using simpler and cool frameworks
    like DWR,dojo,Prototype,GWT,Jmaki,Back Base 4 Struts,Back Base 4 JSF....etc and
    others frameworks like Tomahawk,Ajax4Jsf,ADF Faces,ICE FACES and many others which work with JSF.
    Please Refer
    http://swik.net/Java+Ajax?popular
    http://getahead.org/blog/joe/2006/09/27/most_popular_java_ajax_frameworks.html
    Hope that might help :)
    and finally an advice before implementing anything specfic API which may be related to any technologies (JAVA,javascript,VB,C++...) always refer to API documentation first which always gives you an Idea of implementing it.
    Implementing bad examples posted by people(even me for that matter) directly doesn't make much sense as that would always lands you in trouble.
    and especially when it is more specific to XmlHttpRequest always make habit of refering
    specific Browser site to know more about why specific Object or its property it not working 4i
    IE 6+: http://msdn2.microsoft.com/en-us/library/ms535874.aspx
    MOZILLA: http://developer.mozilla.org/en/docs/XMLHttpRequest
    Safari: http://developer.apple.com/internet/webcontent/xmlhttpreq.html
    Opera 9+: http://www.opera.com/docs/specs/opera9/xhr/
    Hope there are no hard issues on this...
    REGARDS,
    RaHuL

  • Caching JSPs and images...

    I have recently started using pragma's to stop the browser caching jsp files:-
    response.setHeader("Pragma","No-cache");
    response.setHeader("Cache-Control","no-cache");
    response.setDateHeader("Expires",0);
    But will that stop the browser from caching images associated with the page ? I have a background image, which whilst not large, would cause alot of additional bandwidth consumption if it had to be downloaded with every jsp page request.
    Thanks.

    To be honest with you, the browser decides.
    The specification states that if you decide to refresh a web page, the browser should first check to see if there's a new version. If there have been no changes, it should use the version that's already in your "temporary files". The no cache directive is supposed to tell the browser not to bother checking, but go ahead and download the web page again.
    This applies for everything that's on the page. So yes, it would download the background again.
    However, I image that some of the latest generation browsers (such as Opera, Konq, Mozilla and Safari) bend the rules slightly. They recognize that an image is a background image because it's in the body tag, likely to be repeated throughout an entire site, and thus always checks for a new image regardless of whether you cache it or not.
    No cache is just a suggestion, not a requirement. If you're developing in a corporate workspace where everyone is using IE (for example), then I would go ahead and just test it.
    Keep in mind that if your JSP page has to dynamically generate content (usually by accessing a database), then the Servlet Engine always informs the browser that it is a new page. You don't need need to specify no cache in order to get the browser to always look for the most recent version.

  • How to send a text file as jsp response

    Hi
    I want to send a text file/or other file as jsp response ..How to do it..
    Pls tell me if any body knows about it..
    thanks

    Hmmm im no expert but i think you would have to convert it to a byte array and use OutputStream with the response ... not sure ...like i said, im no expert

  • Jsp response performance

    Jsp response performance
              ===================
              The problem:
              We have performance problem while running a jsp-application.
              More specific let's assume the jsp-page generates 1000 lines as a response
              to the browser.
              I've done some testing and if the jsp makes 1000 print.out() it works out
              signaficantly
              slower then to create a StringBuffer(with 1000 lines) and do one print.out.
              Why is that ?
              I thought the print.out where buffered in the response...
              ..Per Lovdinger
              

    Hi,
              When using the "out.print( ... )" in a JSP, I believe that it forces the
              compiled servlet to use a PrintWriter. Servlets that use PrintWriter
              instead of ServletOutputStream, are known to be at least 15% slower.
              If you can, I would suggest using a servlet instead of a JSP.
              Although it does not ultimately answer your question, it does give you some
              idea why the "out.print" is slow, and what you need to do if performance is
              a must!
              Also, 1000 line output is a large output. You may wish to find a way to
              break this into portions, and display it that way.
              -np
              

  • Opera browser caches .jsp pages

    Opera caches .jsp pages.
    This is serious and very annoying because it means that even if I click on the link that leads to the .jsp page I don't see a page with the current situation, but an older one.
    I know that you just use pragma, no-cache etc. in the page to stop caching, but if you use that solution, it also means that you can't use the back button because you won't find the page anymore.
    What I want to do is to say, if the browser is Opera, don't take the cached page, make me a new one.
    Anyone know how to force it not to take a cached page?
    Any help appreciated.

    Are you sure it is Opera, and not a Proxy? We had a problem that looked like the browser but was actually the proxy (because the user that reported it was the only person behind the proxy). At any rate, we handled proxy caching AND browser caching using fake URLS. E.G., When we had a page like http://site/page.jsp that could not ever be cached, we added a bogus parameter that was guaranteed to be unique: http://site/page.jsp?bogusParam=1AFFSDD2. That way the URL was never the same twice and even if the browser or proxy cached it wouldn't matter. Another option if you are using a servlet is to use the path:
    http://site/myservlets/servlet
    becomes:
    http://site/myservlets/1AFFSDD2/servlet
    and you just map that servlet to myservlets/*.
    More hassle, but at least it is workable.

  • Cache JSON response

    Hi,
    I used following blog to Ajaxify a component
    http://blogs.adobe.com/mtg/2011/11/building-components-in-adobe-cq5-part-2-a-tutorial-on-j query-ajax-and-sling.html
    Basically this talks about creating a JSP file in conponent with name [ComponentName].json.POST.jsp to allow running custom code to return JSON.
    My component is doing JCR search based a parameters and returning a JSON list (which could be different for different parameters)
    So all went well till I discover performance issues with AJAX response time.
    Is there a way in CQ5 to cache result of JSON and have it auto every x mins?
    Thanks in adavnce.

    Thanks Justin. I have couple of questions to understand the proposed solution
    1) Do you know how can I convert component POST to GET (for the reference blog). I tried renaming to myajaxsample.json.GET.jsp but it breaks component input dialog. Note that this component is making Ajax call to
    <%= currentNode.getPath() %>.json
    2) Can I force cache to update for cases when data for a particular JSON request is updated?

  • Need some Suggesstions-Improving JSP Response

    Hi Friends,
    This is about improving the response time of the JSPs. I mean I have to display data from a table through a JSP page. The Queries are very heavy. Each time the jsp page is accessed by the user, a database intensive query is executed , which inturn fills the result set and which is further used by the JSP to display the Report/Data of the Result Set. There is one thing that the data is likely, to show a change only once in a period of a Day that is 24 hours. So I believe it is going to be a very intensive operation. Because my JSP has at least 12 links and each link means 12 intensive Queries. SO it means that if I click at a link a Query gets executed (Everytime a click is made) and data is displayed.(The Same Data my get Queried again and again).
    I think Since the Data changes only once in a Day(24 hours).How do I handle this situation without going into one SQL Execution per click of a link kind of Situation.
    Which in turn Reduces the Response time of the JSP to a great extent.
    And I guess makes the process inefficient also. Also toubling tha Database.
    Please Help me with a Way out of it.
    Thanks

    if the result stays the same over a longer period you
    could cache it by writing it as HTML and rebuild it
    periodiclyYou mean to say that I get the Data and create an HTML of the same. and save it.
    And the connect the Link on the Page to the Saved HTML file .
    The JSP is however very complex, Friend.

  • SunOne Web Server 6.1 and JSP response content-length

    Hi,
    I am looking for help for a problem in my previous post
    http://swforum.sun.com/jive/thread.jspa?threadID=58612.
    It seems to me the only significant difference of the response to the same jsp file from 6.0 and 6.1 server is the content-length header.
    6.0 response has the content-length header;
    6.1 response does not have the content-length header.
    HttpUrlConnection::getContentLength() returns the actual content length of the 6.0 response;
    HttpUrlConnection::getContentLength() returns -1 for the 6.1 response.
    Here is the dump,
    SunOne WebServer 6.0
    allowUserInteraction? false
    content? sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@1eed786
    contentEncoding? null
    contentLength? 999
    contentType? application/x-java-jnlp-file
    Date? 1131378080000
    DefaultAllowUserInteraction? false
    DefaultUseCaches? true
    DoInput? true
    DoOutput? false
    Expiration? Wed Dec 31 19:00:00 EST 1969
    FileNameMap? java.net.URLConnection$1@1a1c887
    lastModified? Wed Dec 31 19:00:00 EST 1969
    requestMethod? GET
    responseCode? 200
    responseMessage? OK
    HEADER::Set-cookie=[JSESSIONID=pkand013-1%253A436f75a0%253A5b909ee2e5bbe3bc;path=/]
    HEADER::Date=[Mon, 07 Nov 2005 15:41:20 GMT]
    HEADER::Server=[Netscape-Enterprise/6.0]
    HEADER::null=[HTTP/1.1 200 OK]
    HEADER::Content-length=[999]
    HEADER::Content-type=[application/x-java-jnlp-file]
    SunOne WebServer 6.1
    allowUserInteraction? false
    content? sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@1fee6fc
    contentEncoding? null
    contentLength? -1
    contentType? application/x-java-jnlp-file
    Date? Mon Nov 07 10:49:07 EST 2005
    DefaultAllowUserInteraction? false
    DefaultUseCaches? true
    DoInput? true
    DoOutput? false
    Expiration? Wed Dec 31 14:00:00 EST 1969
    FileNameMap? java.net.URLConnection$1@1503a3
    lastModified? Wed Dec 31 19:00:00 EST 1969
    requestMethod? GET
    responseCode? 200
    responseMessage? OK
    HEADER::null=[HTTP/1.1 200 OK]
    HEADER::Expires=[Wed, 31 Dec 1969 19:00:00 EST]
    HEADER::Set-cookie=[JSESSIONID=44A318F4BC0802A4C70C27FD4AB1C115;Path=/]
    HEADER::Transfer-encoding=[chunked]
    HEADER::Date=[Mon, 07 Nov 2005 15:49:07 GMT]
    HEADER::Pragma=[No-cache]
    HEADER::Server=[Sun-ONE-Web-Server/6.1]
    HEADER::Content-type=[application/x-java-jnlp-file]
    HEADER::Cache-control=[no-cache]
    In my test env, 6.0 and 6.1 are installed on the same machine (Win2K), using the same directory as web root, same http port. Browser runs on a different machine.
    Thanks
    Harry

    Hi, elving
    This is good information. Thanks very much.
    Actually, I am not using SSL, just plain http connection with basic auth. It might be the cache-control header that causes the head ache. 6.0 response does not have the cache-control header, but 6.1 has.
    The interesting thing is that adding a servlet mapping on 6.1 solves the problem.
    I will take a further look tomorrow.
    Cheers,
    Harry
    I doubt the problem has to do with the Content-Length
    header.
    I'd guess that you're using SSL. Are you? If so,
    you're almost certainly bumping into a known bug (or,
    as Microsoft describes it, a "feature") in Internet
    Explorer. Microsoft article KB316431 at
    http://support.microsoft.com/default.aspx?scid=316431h
    as some information on the problem. As the article
    points out, the problem occurs when Internet Explorer
    needs to invoke an external application to handle a
    file that was served over SSL with Cache-Control:
    no-cache and/or Pragma: no-cache headers.
    A work around would be force Web Server to send
    Cache-Control and Pragma headers that don't include
    the no-cache directive. For example, the following
    lines could be added to the obj.conf configuration
    file:<Object ppath="*.jnlp">
    Output fn="set-variable" set-srvhdrs="Cache-Control:
    private"
    Output fn="set-variable" set-srvhdrs="Pragma:
    private"
    </Object>Fortunately, it sounds like you've already
    found another viable work around.

  • JSP Response Slow in OC4J

    Hi,
    I have a web application (jsps and servlets accessig to an oracle database) deployed by jdeveloper 10g in OC4J Standalone 10g, the problem appears when my aplication turned very slow where i go to a jsp page, only the html pages are fast but my jsps not, this appears incomplete because of the slow response, the pc that i install oc4j has 1GB memory, and i don't know what to do, please help me to find out why is this happening, i did the same thing in opther pc and i have no problems, so in this pc why is it happening.
    Thanks

    David, I do not think that oc4j 10.1.2 is certified with jdk-1_5_0_03. It is certified with JDK 1.3.1 and JDK 1.4.1, although it is quite possible that it can be run with other jdk versions.
    I can not see why your jsp is running incredibly slow. From what you provided, it seems that the process is stuck somewhere inside the _jspService method of the jsp page. To confirm that, it is much easier for you do a little more debugging. Just insert
      <% System.out.println(System.currentTimeMillis()); %>
    into various places of your jsp. Also, you may make a thread dump by "ctrl^break" on Windows or "ctrl^\" on Unix from time to time so as to find which methods stay on top of the stacks of the running threads. Then we can pinpoint the places that take most of the time.

  • Problem in SXI Cache refresh:Response Code 503

    Hi all,
    The SXI cache contents are not getting refreshed automatically on making changes in the Directory or Repository. Also, I am unable to refresh the cache contents manually in transaction SXI_CACHE.
    I get the following error on refreshing: Response Code 503: Service Unavailable.
    The RFC Destination INTEGRATION_DIRECTORY_HMI has correct entry in the URL(Path Prefix) and Test Connection from SM59 is working fine.
    How do I make this work?
    Regards,
    Puloma Chaudhuri.

    Hi all,
    The exact nature of the error on refreshing in SXI_CACHE is:
    CacheRefreshRepositoryCommunicationException: Attempt to access application <b>REPOSITORY</b> using Http Method Invocation (<b>HMI</b>) failed. Detailed information: <b>Invoking ROA method "ReadObjects"</b> via HMI ... FAILED due to following exception: Message: Connection to system REPOSITORY using application REPOSITORY lost. Detailed information: Error accessing "http://server:50000/rep/remoteobjectaccess/int?container=ejb" with user "<b>XIDIRUSER</b>". Response code is 503, response message is "Service Unavailable"
    Does that narrow it down?
    Regards,
    Puloma Chaudhuri.

  • Caching JSP output

    All,
              Any help or pointers to solutions would be greatly appreciated.
              We have some JSPs that produce relatively static output. Is there a way in
              WL to cache the output, instead on recreating it every time? I know that
              the Caucho JSP engine will do this (it uses browser caching directives).
              Would we need to create our own caching mechanism?
              Thanks,
              Wade Matveyenko
              

    Good idea, I'll file it as a per.
              Sam
              "Dimitri Rakitine" <[email protected]> wrote in message
              news:[email protected]...
              > Oh. Then why not use maxSize cache backed by the SoftReferences?
              > For example, in the BubblingCache store hard references:
              >
              > class KeyValuePair {
              > public Object key;
              > public Object value; // hard reference to prevent cached object
              > // from being gc'ed.
              > }
              >
              > in the sorted array and SoftReferences in the HashMap - that way it will
              > behave like a normal maxSize cache and, if we are lucky, will be able to
              > return cached objects even after their hard references are removedi
              (maxSize
              > reached). If the garbage collector is too eager to clear SoftReferences
              there
              > will be no performance penalty.
              >
              > Sam Pullara <[email protected]> wrote:
              > > Essentially, soft references in HotSpot are not useful as caches. Here
              is
              > > the bug/per from the
              > > Java Developer Connection:
              >
              > > http://developer.java.sun.com/developer/bugParade/bugs/4239645.html
              >
              > > What you find is that your newly made soft reference rarely makes it to
              the
              > > long term generation
              > > in the collector and thus gets cleared almost immediately. There is
              some
              > > stochastic effect that
              > > smoothes it somewhat over time but it is nothing like the perfect
              behaviour
              > > you get from the classic
              > > virtual machine.
              >
              > > Although the tag detects what VM it is in and determines a good default,
              > > there is the ability to
              > > force softreferences either on or off. You can set either
              >
              > > weblogicx.jsp.tags.CacheTag.softreferences=true
              > > or
              > > weblogicx.jsp.tags.CacheTag.nosoftreferences=true
              >
              > > To force it one way or the other. These are System properties, not
              WebLogic
              > > properties, so you
              > > will either need to set them on the command line with -D or you can use
              the
              > > special weblogic.properties
              > > syntax and prepend java.system.property to the property names to set
              them,
              > > like:
              >
              > > java.system.property.weblogicx.jsp.tags.CacheTag.softreferences=true
              >
              > > Some of the documentation is a tad out of date. There will be a more
              formal
              > > release of the tag library
              > > in the next release of the WebLogic Server.
              >
              > > Sam
              >
              > > "Dimitri Rakitine" <[email protected]> wrote in message
              > > news:[email protected]...
              > >> It says: 'Unfortunately, due to incompatibilities with the HotSpot's VM
              > > and the Classic VM, we must
              > >> not use soft references when we are running within HotSpot. '
              > >>
              > >> Could you please elaborate what these incompatibilities are?
              > >>
              > >> Thanks.
              > >>
              > >> Sam Pullara <[email protected]> wrote:
              > >> > Service Pack 5 includes a cache tag. Attached is a war file with the
              > >> > javadocs.
              > >> > You should find it in lib/weblogic-tags-510.jar or use the one in the
              > > war
              > >> > file.
              > >>
              > >> > Sam
              > >>
              > >> > "Dimitri Rakitine" <[email protected]> wrote in message
              > >> > news:[email protected]...
              > >> >> You can use squid (http://www.squid-cache.org) in front of your
              > >> >> Weblogic server(s) - it will do caching for you.
              > >> >>
              > >> >> Wade Matveyenko <[email protected]> wrote:
              > >> >> > All,
              > >> >> > Any help or pointers to solutions would be greatly appreciated.
              > >> >>
              > >> >> > We have some JSPs that produce relatively static output. Is there
              a
              > > way
              > >> > in
              > >> >> > WL to cache the output, instead on recreating it every time? I
              know
              > >> > that
              > >> >> > the Caucho JSP engine will do this (it uses browser caching
              > > directives).
              > >> >> > Would we need to create our own caching mechanism?
              > >> >>
              > >> >> > Thanks,
              > >> >> > Wade Matveyenko
              > >> >>
              > >> >> --
              > >> >> Dimitri
              > >> >> http://dima.dhs.org
              > >>
              > >> --
              > >> Dimitri
              > >> http://dima.dhs.org
              >
              > --
              > Dimitri
              > http://dima.dhs.org
              

  • Q: WLS 7 Cache Filters (Response Caching) Keys, Vars?

              I can't seem to find any better docs about setting up cache filters than this
              http://edocs.bea.com/wls/docs70/servlet/progtasks.html#response_caching
              specifically, what are some examples of the init params, Keys and Vars?
              - especially in use with Servlets.
              Can Keys be Attribute names? Parameter names? Headers? Cookies? Other?
              And then what are examples of Vars?
              "variables calculated by the page that you want to cache"
              Does that really mean, it's cacheing a variable, like a resultset calculated in
              the doGet, instead of the page (response)? If so what can those be? Or should
              that have said "variables used to calculate the page"?
              Let's say I have a Servlet which might be called like
              myservlet?param1=A&param2=B&param3=C
              and there are a few cookies, cookie1=X;cookie2=Y;cookie3=Z
              In this case, only param1, param2, cookie1 can actually make a difference in the
              response. So I want my cached keyed off those (and only those).
              what would it look like?
              <init-param>
              <param-name>Key</param-name>
              <param-value>?</param-value>
              </init-param>
              <init-param>
              <param-name>Vars</param-name>
              <param-value>?</param-value>
              </init-param>
              

    We are in process of updating the docs for cache filter. So they should be
              in
              better shape soon. Sorry for the inconvenience.
              Here is an example:
              <filter>
              <filter-name>CacheFilter</filter-name>
              <filter-class>weblogic.cache.filter.CacheFilter</filter-class>
              <init-param>
              <param-name>scope</param-name>
              <param-value>session</param-value>
              </init-param>
              <init-param>
              <param-name>timeout</param-name>
              <param-value>30m</param-value>
              </init-param>
              <init-param>
              <param-name>size</param-name>
              <param-value>10</param-value>
              </init-param>
              <init-param>
              <param-name>key</param-name>
              <param-value>parameter.userid,parameter.clientip</param-value>
              </init-param>
              <init-param>
              <param-name>vars</param-name>
              <param-value>request.var1,request.var2,request.var3</param-value>
              </init-param>
              </filter>
              <filter-mapping>
              <filter-name>CacheFilter</filter-name>
              <url-pattern>/cached/*</url-pattern>
              </filter-mapping>
              Various scopes:
              parameter -> request parameter
              request -> request attribute
              requestHeader -> request header
              responseHeader -> response header
              session -> http session
              application -> context
              cluster -> cluster scope (need to configure cluster listener for this)
              key:
              Syntax: Comma separated list of <scope>.<attribute name>
              Typically a given cache is identified by it's cache name that you configured
              in web.xml.
              If that's not specified the request uri is used as a cache name. But using
              keys you can
              specify additional values to identify a tag. For example if you want to
              separate out the
              cache for a given end user, then in addition to the cache name you can
              specify the keys
              as the userid, values for which you want to pick it up from the request
              parameter scope
              (query param/post params) plus perhaps a client ip. So you will specify your
              keys as:
              "parameter.userid,parameter.clientip"
              Here "parameter" is the scope (request parameter scope) and
              "userid"/"clientip" are the parameters/attributes.
              This means the primary key for the cache becomes the cache name (request uri
              in this
              case) + value of userid request param + value of clientip request param.
              Note: If you don't specify the scope the cache system will search all the
              scopes
              for the attribute.
              size:
              For caches that use keys, the size element defines the number of entries
              allowed.
              The default is an unlimited cache of keys. With a limited number of keys the
              tag
              uses a least-used system to order the cache (BubblingCache).
              vars:
              Same syntax as the key:
              Syntax: Comma separated list of <scope>.<attribute name>
              Variables are used to do input caching. So you can save the variables you
              used to calculate the cache. When the cache is retrieved the variables are
              restored back to the scope you specified. For example for retrieving results
              from
              a database you used var1 from request param, var2 from session etc. So
              when the cache is created the value of these variables are stored with the
              cache. When the cache is accessed next time these values are restored
              so you will be able to access them from respective scopes. For example
              var1 will be available from request and var2 from session.
              Hope this helps.
              --Vinod.
              "Stek" <[email protected]> wrote in message
              news:[email protected]...
              >
              > I can't seem to find any better docs about setting up cache filters than
              this
              >
              > http://edocs.bea.com/wls/docs70/servlet/progtasks.html#response_caching
              >
              > specifically, what are some examples of the init params, Keys and Vars?
              > - especially in use with Servlets.
              >
              > Can Keys be Attribute names? Parameter names? Headers? Cookies? Other?
              >
              > And then what are examples of Vars?
              > "variables calculated by the page that you want to cache"
              > Does that really mean, it's cacheing a variable, like a resultset
              calculated in
              > the doGet, instead of the page (response)? If so what can those be? Or
              should
              > that have said "variables used to calculate the page"?
              >
              > Let's say I have a Servlet which might be called like
              > myservlet?param1=A&param2=B&param3=C
              > and there are a few cookies, cookie1=X;cookie2=Y;cookie3=Z
              >
              > In this case, only param1, param2, cookie1 can actually make a difference
              in the
              > response. So I want my cached keyed off those (and only those).
              >
              > what would it look like?
              >
              > <init-param>
              > <param-name>Key</param-name>
              > <param-value>?</param-value>
              > </init-param>
              > <init-param>
              > <param-name>Vars</param-name>
              > <param-value>?</param-value>
              > </init-param>
              >
              

  • GSS (vs) Cached DNS responses

    I am trying to understand the GSS product and how it provides 'immediate' redundancy across multiple data center(s).
    So lets assume that the GSS (with CNR installed) has been deployed and functions as the authoritative server for the domain (www.test.com). The goal is to provide active/standby type configuration between two data centers.
    If a client tries to access the page (www.test.com), the GSS replies with the address of server (e.g: 1.1.1.1) residing in Data Center(a). However lets assume after the response from GSS is sent to client and the client is trying to connect to the www.test.com using Ip address 1.1.1.1, Data Center(a) becomes unavailable. How will this connection get redirected to Data Center(b)'s IP address 2.2.2.2?
    All subsequest request from the client will be done using 'DNS cache' so the GSS does not come into the picture since the client already knows the IP address of www.test.com (1.1.1.1).
    Is this how it works or am I missing something here?
    Thanks in advance for the response.

    Syed
    There are few things you should keep in mind.
    User Workstation is not the real client for GSS. Its primarily the Client's DNS Server.
    With respect to caching you are very correct that GSS (for that matter any DNS based GSLB method) is prone to DNS caching issues.
    There are various points in the network that stores/caches DNS information.
    1. Client's DNS Servers
    2. Client PC's OS
    3. Browser on Client's PC
    To mitigate Client DNS Server issue you need configure the A record served by GSS with a smaller TTL value. This "A-record TTL value" dictates how long can DNS server caches a DNS record. So for example if you set A-record TTL value to 5 minute then the worst outage of service you will get will be 5 minutes (as Client's DNS server will only cache it for 5 minutes and at 6th minute Client's DNS server will contact GSS again and will get the active vip as answer.
    If you are using newer IE versions (6.x+) then you are in a better situation as these IEs try to resolve again if the web access to IP in DNS cache fails and hence will get the active IP on GSS.With Pre-6.x versions problem is severe as not only this feature is missing but also the DNS caching time is from 30 mins to 24 hours.
    With Firefox (last time I checked) this dns cache timeout is 15 minute (so in worst case scenario the service outage will be 15 minutes).
    Using google you can get lots of tools to disable dns caching on browsers. I know this is not a cool solution but it can be done.
    In nutshell yes GSLB has issues with DNS caching but it still gives you a solution which can move client to a different Data center (after dns cache timeout).
    Syed Iftekhar Ahmed

  • URGENT HELP ON white space in jsp response

    I have written a jsp and printing a String at the end of jsp.Only one out.print() statement is used in the whole jsp page but the output(when we use view source) comes with lot of white space(new line characters) before the string. Actually I want only string in the response nothing else(no html code,no white space).As this string to be send as sms to mobile.
    pseudo code
    <%@ page language="java" contentType="text/plain" %>
    <%
    String text="";
    do processing
    out.println(text);
    %>
    When I see OUTPUT using view source The output is Loke this with lots of white Spaces
    String output
    </body>
    </html>
    these html tags and spces are not desirable.
    Please provide the solution .
    thanks in advance.

    I believe the white space is due to empty println statements created by jspc - jasper
    you can get rid of the spaces by setting the trimSpaces parameter to true in your web.xml
    It will be more efficient than a filter also text that is marked as <pre> or that has
    style="white-space: pre" will not be affected.
    Andrew Bailey
    www.hazlorealidad.com
    Example:
    <servlet>
    <servlet-name>jsp</servlet-name>
    <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
    <init-param>
    <param-name>fork</param-name>
    <param-value>false</param-value>
    </init-param>
    <init-param>
    <param-name>trimSpaces</param-name>
    <param-value>true</param-value>
    </init-param>
    <init-param>
    <param-name>xpoweredBy</param-name>
    <param-value>false</param-value>
    </init-param>
    <load-on-startup>3</load-on-startup>
    </servlet>

Maybe you are looking for