Cache XSLT in Servlets

Guys, I have written a servlets which create an xml file .... depends on JSP form... i want to run my xslt on it and produce .csv and .html..... I have two xslt file... I was wondering if i can store xslt file in cache... because it's taking to long to download... is there any better way to do it?
O'reilly....
mentioned of javax.xml.transform.Templates interface
Source xsltSource = new StreamSource(xsltFile);
TransformerFactory transFact = TransformerFactory.newInstance();
Templates cachedXSLT = transFact.newTemplates(xsltSource);
Transformer trans = cachedXSLT.newTransformer();
is this a good way to do it? or is there any other better way...
how about...
HashMap cachexslt = new HashMap();
cachexslt.put("HTML", filename);
cachexslt.put("CSV", filename):
if (formatType,equals("HTML")
cachexslt.get("HTML") and run it on my xml file
else run my csv xslt on xml file...
-Sumit

O'Reilly is correct. The Templates object is reusable and can be cached.

Similar Messages

  • Caching XSLT results?

    Hi,
    I am a newbie to XML/XSLT, and we have just written our first XSL stylesheet.
    I am using the WebLogic JSP Tag Library to do the transformation from XML to HTML
    and all seems to work well. My question is this: Does WebLogic cache the HTML
    somewhere so that the transformation does not need to be reperformed each time
    the page is requested by the user? It sounds like an obvious thing to do, but
    I'm not sure if this functionality is included in WebLogic. If it is not, are
    there others out there who have this same need (to cache XSLT results for performance
    reasons) and how have you dealt with this issue. Any help would be appreciated.
    I'm running WLS 6.0 SP2 on HP-UX 11.x. Thanks...
    Vasuki.

    I tried this example based on a view:
    CREATE MATERIALIZED VIEW MV_TEST2
         REFRESH COMPLETE
         START WITH SYSDATE
         NEXT  SYSDATE + 1/48
         WITH ROWID
         AS SELECT * FROM test1;REFRESH COMPLETE -- The complete refresh re-creates the entire materialized view.
    START WITH SYSDATE -- run now
    NEXT SYSDATE + 1/48 -- run again in half an hour
    WITH ROWID -- I think this option is important if you use partial refresh of the view.
    AS SELECT * FROM test1; -- test1 is a view:
    CREATE OR REPLACE VIEW TEST1 AS
    SELECT st_id, st_name
        FROM aaw_solution_tree;Are column indexes still possible? I'm not sure:
    Indexing: !with respect to MV's on 10gR2 Jonathan Lewis wrote! ... you are allowed to create indexes on the tables that sit under materialized views - just don't make them unique indexes
    How much freedom is there in setting the refresh rate?
    What type of refreshing do you need?
    Another useful link: [http://asktom.oracle.com/pls/ask/search?p_string=materialized+view|http://asktom.oracle.com/pls/ask/search?p_string=materialized+view]
    Hope it helps.
    Tobias

  • Cache problem for servlet opening new browser window

    Requirement:
    I have JSP page say summary.jsp with link "print account summary"
    When user clicks on this link, new browser open with PDF document of summary.jsp
    This new browser window should not have address bar and toolbar.
    Solution:
    Servlet called PrintSummary which sets contenttype=application/pdf and sends the data to outputstream.
    href of link is
    Java script function is:
    function openWindow(url){
    window.open(url,'blank','toolbar=no')
    Problem:
    Since the URL of this new window is
    http:// host:portnumber/PrintSummary
    Even if I click the "Print summary" link for account2,
    being the same URL (http:// host:portnumber/PrintSummary) it accesses the existing page in the cache which is created for account 1.
    In href if I just use servlet url as
    I get the expected behaviour but then I don't have control on browser appearance and browser window will be with address bar and toolbar.
    The only option I could think of was changing URL as follows:
    <% String url ="javascript:openWindow('PrintSummary? var1="+ Math.random()+"')";
    So that URL is different all the time
    Is there any way to solve this problem?
    Thanks in advance
    M.

    I'd definitely try to use a Flex popup... but the
    flash.net.navigateToURL method is a simple way to open a popup
    window in a new browser. You can pass any data needed by the new
    page using the URLRequest and/or URLVariables. The URL you navigate
    to could, of course, be another Flex application if necessary. I
    use this only when I need to open a popup window on another site,
    or an HTML formatter report or something similar.
    Concerning yourself with the size of the popup window may be
    a bad design choice also. I, for example, have my browser
    configured to open all popups in a new tab regardless of sizing
    constraints imposed by the designer. If it is absolutely necessary
    for you to have control over the size of your popup window, you
    should follow the advice given by others and use a Flex
    popup.

  • Caching problem of servlet

    Hi guys
    We are facing this problem of caching within our project. The project aims to generate a html code to pick up some rich media ads details at random and displaying on the html file where the generated code is expected to be pasted. We developed two servlets, one which extracts the ads from the database randomly and then depanding on the ad type it calls the other servlet as src of an iframe, which in turn puts all code for displaying the rich media ads. The script which we are generating for the user to paste onto their pages is:
    <script LANGUAGE="JAVASCRIPT" src="http://192.168.1.6:8080/advert_java/servlet/GetAdServlet?region=1&zone=1&type=nossi&cachevar=yes">
    </script>First servlet (GetAdServlet) returns the javascript statements and thus is called using this generated code. Now cotents of the iframe are supplied by the second servlet ie richMediaServlet. This servlet is called like
    iframeURL = fullHttpDir+"/servlet/RichMediaServlet?";
    iframeURL += "bannerCode="+ RNBanner (BannerCode to be called);
    out.println("document.write(\"<iframe  src='"  + iframeURL +  "' height=" + hheight +" width="+ wwidth + " SCROLLING=no FRAMEBORDER=0 MARGINWIDTH=2 MARGINHEIGHT=2 onfocus='window.focus(); return iframeFocus()'>\");");
    out.println("document.write(\"</iframe>\");");This richmediaServlet returns HTML into <iframe>. when richmediaservlet is called, a parameter 'bannerCode' is passed. then richmediaServlet fatches the banner from the database and displays the banner into the <iframe>.
    Now the problem comes when we run the html file containing the script tag mentioned above, and refresh our page, ideally it should pick the ads randomly and pass it on to RichMediaServlet.
    I also try debugging both servlets. I called the getadservlet from javascript mentioned above and put debugging info in both the servlets, now for every refresh we do on the html side, we are getting a different random bannercode in adservlet but in richmedia when we print the bannercode received in querystring it is taking an older value which was displayed some time back and keeps on doing this for quiet a long time, making it look like some caching problem of RichMediaServlet.
    Instead when we tried to put the same html <script> code into another servlet's doGet, everything seems to be working fine.
    i have also used the following code to prevent the caching on both the setvlets
    long currentTime = System.currentTimeMillis();
    response.setHeader("Cache-Control", "no-cache, must-revalidate");
    response.setHeader("Pragma", "no-cache");
    response.setDateHeader("Last-modified", currentTime);
    response.setHeader("Expires", "Sat, 6 May 1995 12:00:00 GMT");     and following in the iframe's head tag before the iframe tag in the getAdServlet.
    out.println("document.write('<head>');");
    out.println("document.write('<meta http-equiv=\"Cache-Control\" content=\"no-cache,must-revalidate\">');");
    out.println("document.write('<meta http-equiv=\"Pragma\" content=\"no-cache\">');");
    out.println("document.write('<meta http-equiv=\"Last-modified\" content=\""+ currentTime + "\">');");
    out.println("document.write('<meta http-equiv=\"expires\" content=\"Sat, 6 May 1995 12:00:00 GMT\">');");
    out.println("document.write('</head>');");I request you all geeks to try and help me to your best. The project is at its final stages and in high urgency now.

    i think the caching is being in the browser, with the iframe.
    You should try passing a random param to the servlet in the iframe URL, something like:
    var a = Math.random() * 10000000; //for example
    out.println("document.write(\"<iframe  src='"  + iframeURL +"&rand="+a+"' height=" + hheight +" width="+ wwidth + " SCROLLING=no FRAMEBORDER=0 MARGINWIDTH=2 MARGINHEIGHT=2 onfocus='window.focus(); return iframeFocus()'>\");");
    out.println("document.write(\"</iframe>\");");
    ...It should force the browser to ask for the servlet again
    hope this helps...

  • Xslt with servlets

    i am trying to display a list of records from a from a query on a webpage using servlets.
    i need to create a link such as this:
    <a href = "/fic/main?task=viewPage&id=1">view page</a>
    the problem is the "id" field need be the value that is in that record. i tried using
    <xsl:value-of select="id"/> inside the href tag, however i get an error. i know there must be an easy what to do this, but i can seem to find an docs on it!!!
    can you help?
    thanx,
    matt

    I don't see why this is a question about servlets, but anyway if you're asking how to do that in XSLT, I would suggest an attribute value template:
    <a href = "/fic/main?task=viewPage&id={id}">view page</a>

  • Application Server 4.0 caching the Java Servlet Program

    Hi all,
    I am working with Oracle8i databse and Oracle Application Server 4.0. Now I need to develop some Java Servlet's Program. I successful configure the server and my Servlet program can connect to the Oracle database.
    However, when I make some modification to the program and recompile it. The browser cannot refresh to the modified program. This mean that the content is't update. I think the reason may be the previous program is cached in server.
    Later, I discover using the 'owsctl' utility to reload the application server can solve this problem. However, it is quite inconvenience and not favour to reloasd the server very frequently. And I guess there may have some configuration parameters in the 'OAS Manager' can help me to solve my problem.
    So, anyone can tell me how to solve this problem? Thank you very much.
    Regards

    OAS 4.0.8.1 supports servlets. You need a patch if you implement extra path info feature of servlets. In addition, you have to bounce OAS everytime you upload new servlets. This behavior does not follow the Servlet spec and I don't know when Oracle will fix it. It is a big problem for sites trying to run 24x7.
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by dlnoida:
    Dear All,
    I have an application built in applets, i wants to host them on OAS 4.0.7.
    How can i do it if possible? Do i reqire any third party tool for it ?
    Is OAS 4.0.8 supports servlets?<HR></BLOCKQUOTE>
    null

  • [ExtermlyUrgent]How can we implement our own caching scheme in servlets???

    Hi all,
    anyone, give me any idea about implementing our own cahing sechme in servelts. Please guide me with your knowledge i also need a running sample source code to understand this concept. It is extrememly urgent please help me .
    Regards.

    try to use
    http://cvs.apache.org/viewcvs/jakarta-commons-sandbox/cache/
    or
    http://jakarta.apache.org/turbine/jcs/
    if u are looking for a simple caching.. do it programatically.
    regards,
    Arun
    http://www.javageekz.com/

  • XSLT Caching

    HI,
    I am using JAXP Template object to cache my XSLT files. Can my code pass parameters to a cached XSLT file?
    Thanks,
    Java-Junkie

    I am using the following code to handle my transforms, can you suggest how I would cache the xslt files?
    import javax.xml.transform.*;
    import javax.xml.transform.stream.*;
    import java.util.*;
    import java.io.*;
    public class TransformerPool
    /** Source control version number. */
    public final static String SOURCE_VERSION_INFO = "%R%";
    /** Minimum number of transformers per transformation. */
    public final static int MIN_INSTANCES = 1;
    /** Maximum number of transformers per transformation. */
    public final static int MAX_INSTANCES = 5;
    // class members
    private static TransformerFactory tFactory;
    private static TransformerPool thisTP;
    // data members
    private Map transformers;
    private int defaultMinInstances;
    private int defaultMaxInstances;
    private class PoolEntry
    private int minInstances;
    private int maxInstances;
    private int currentInstances;
    private int hits;
    private int waitStates;
    private int waitIter;
    private StreamSource xslDocument;
    private boolean busy[];
    private Transformer processors[];
    public PoolEntry(TransformerPool source, String xslDocument)
    init(source);
    initTransformer(xslDocument);
    public PoolEntry(TransformerPool source, StreamSource streamSource)
    init(source);
    initTransformer(streamSource);
    public void init(TransformerPool source)
    minInstances = source.defaultMinInstances;
    maxInstances = source.defaultMaxInstances;
    currentInstances = minInstances;
    hits = 0;
    waitStates = 0;
    waitIter = 0;
    public void initTransformer(String xslDocument)
    initTransformer(new StreamSource(new StringReader(xslDocument)));
    public void initTransformer(StreamSource xslDocument)
    this.xslDocument = xslDocument;
    busy = new boolean[maxInstances];
    processors = new Transformer[maxInstances];
    for ( int i=0; i<maxInstances; i++ )
    busy[i] = false;
    processors[i] = i < currentInstances ? newTransformer() : null;
    private Transformer newTransformer()
    synchronized (TransformerPool.tFactory)
    try
    Templates cashedXSLT = TransformerPool.tFactory.newTemplates(xslDocument);
    Transformer trans = cashedXSLT.newTransformer();
    return trans;
    //return TransformerPool.tFactory.newTransformer(xslDocument);
    catch (TransformerConfigurationException e)
    return null;
    public boolean transform(Source xml, Result result, Properties params)
    boolean isBusy = false;
    boolean allNull = false;
    Transformer xform = null;
    int index = -1;
    do
    if (isBusy)
    try
    Thread.currentThread().sleep(100);
    catch (InterruptedException e)
    synchronized (this)
    allNull = true;
    for ( int i=0; i<maxInstances; i++ )
    if (processors[i] != null)
    allNull = false;
    if (processors[i] != null && busy[i] == false)
    index = i;
    xform = processors;
    busy[i] = true;
    isBusy = false;
    break;
    if (allNull == true) // theres nothing we can do; fail
    return false;
    if (index == -1)
    waitIter++;
    isBusy = true;
    } while (isBusy);
    // we should have a transformer now
    try
    String paramName;
    xform.clearParameters();
    if(params!=null){
    for ( Enumeration e=params.propertyNames(); e.hasMoreElements(); )
    paramName = (String)e.nextElement();
    xform.setParameter(paramName, params.get(paramName));
    Message.out(Message.DEBUG, "starting transform");
    xform.transform(xml, result);
    Message.out(Message.DEBUG, "ending transform");
    catch (Exception e)
    e.printStackTrace();
    Message.out(Message.DEBUG, "exception? " + e.toString());
    return false;
    finally
    if (xform != null)
    synchronized (this)
    busy[index] = false;
    // increment counters
    if (isBusy)
    waitStates++;
    hits++;
    return true;
    * Create a new {@link TransformerPool}.
    private TransformerPool()
    if (tFactory == null)
    tFactory = TransformerFactory.newInstance();
    transformers = new HashMap();
    defaultMinInstances = MIN_INSTANCES;
    defaultMaxInstances = MAX_INSTANCES;
    * Create a new {@link TransformerPool}.
    * @return A {@link TransformerPool} instance.
    public static synchronized TransformerPool getInstance()
    if (thisTP == null)
    thisTP = new TransformerPool();
    return thisTP;
    private synchronized PoolEntry newEntry(StreamSource xsl)
    return xsl == null ? null : new PoolEntry(this, xsl);
    public synchronized void dump(PrintWriter out)
    PoolEntry entry;
    String key;
    out.println("Default instances: " + defaultMinInstances +
    " (minimum), " + defaultMaxInstances + " (maximum)");
    out.println("Transfomers: " + transformers.size());
    out.println();
    for ( Iterator iter=transformers.keySet().iterator(); iter.hasNext(); )
    key = (String)iter.next();
    entry = (PoolEntry)transformers.get(key);
    out.println("Transformer: " + key);
    out.println(" Instances: " + entry.minInstances + " (minimum), " +
    entry.maxInstances + " (maximum), " + entry.currentInstances +
    " (current)");
    out.println(" Hits: " + entry.hits + " (" + entry.waitStates + " busy)");
    for ( int i=0; i<entry.maxInstances; i++ )
    out.println(" (" + i + ") " + entry.processors[i] + " " + (entry.busy[i] ? "busy" : "not busy"));
    out.println();
    out.flush();
    * Add a new transformation.
    * @param name Transformation name as a String.
    * @param xsl Transformation XSLT document as a StreamSource.
    public synchronized void addTransformation(String name, StreamSource xsl)
    PoolEntry entry = newEntry(xsl);
    if (entry != null)
    transformers.put(name, entry);
    * Remove a given transformation.
    * @param name Transformation name as a String.
    public synchronized void removeTransformation(String name)
    transformers.remove(name);
    * Determines if a given transformation exists.
    * @param name Transformation name as a String.
    * @return <code>true</code> if there is a transformation by that
    * name, otherwise <code>false</code>.
    public synchronized boolean isTransformation(String name)
    return transformers.containsKey(name);
    * Transform an XML document using a named transformation.
    * @param name Transformation name as a String.
    * @param xml XML document to transform as a Source.
    * @param result Transformed document as a Result.
    * @return <code>true</code> if the transformation succeeded or
    * <code>false</code> if the transformation couldn't be completed
    * for any reason.
    public synchronized boolean transform(String name, Source xml, Result result)
    // find the entry
    PoolEntry entry = (PoolEntry)transformers.get(name);
    if (entry == null)
    return false;
    // transform
    return entry.transform(xml, result, null);
    * Transform an XML document using a named transformation.
    * @param name Transformation name as a String.
    * @param xml XML document to transform as a Source.
    * @param result Transformed document as a Result.
    * @param params Collection of transformation parameters as Properties.
    * @return <code>true</code> if the transformation succeeded or
    * <code>false</code> if the transformation couldn't be completed
    * for any reason.
    public synchronized boolean transform(String name, Source xml, Result result, Properties params)
    // find the entry
    PoolEntry entry = (PoolEntry)transformers.get(name);
    if (entry == null)
    return false;
    // transform
    return entry.transform(xml, result, params);

  • Servlet side Cache implementation - need cache (updateable, portable) in Servlet

    Hi Guys,
              Any ideas on implementing an updateable cache on a servlet. The problem is
              that
              it must be updateable (I must be able to tell it to update itself whenever a
              welldefined
              event occurs), and it must work in a cluster environment, and I would prefer
              it to
              be J2EE portable.
              I know I can poll from the servlet - but this isn't the most elegant
              approach.
              My servlet needs to do some really fast security/auditing, but I don't want
              it to
              always do something like an EJB lookup. I can quite easily cache what I
              need
              in the hashmap - problem is updateing it and also having it work in a
              clustered
              environ.
              Any other ideas appreciated,
              Jon
              

    ejp wrote:
    Of course it is. That's how any Map behavesWhen a key has been discarded its entry is effectively removed from the map, so this class behaves somewhat differently than other Map implementations. I meant, the mapping doesnt prevent the key from getting discarded cause it is a weakreference.
    No: it's out of your control, but it's within the garbage collector's control. That is the purpose of the class.You aint talking about the situation written in this email. So if it is out of control, your suggestion about weakhashmap isn't gonna work. Out of control in the sense, it doesnt treat a key which was recently accessed any different from anything which wasn't accessed for a long time.
    Because by choosing a key that will get garbage-collected at the time of interest to you, you ensure that the WeakHashMap will drop the corresponding value at the same time as the key is GC'd.Not realted to the problem above. Summarily WeakHashmap is no good for the above scenario.

  • Prevent servlet caching

    I am having problem with servlet caching. My Servlet keeps displaying
    previously cached image instead of an updated image. I tried out the
    following workarounds and was not successful.
    1. Set the following Response headers
    res.setDateHeader("Expires", 0);
    res.setHeader("Cache-Control", "no-store, no-cache, must-revalidate,
    post-
    check=0, pre-check=0");
    res.setHeader("Pragma", "no-cache");
    2. Set HTML META TAG:
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="Expires" CONTENT="0">
    Has anyone experienced a similar issue and can you share your
    worarounds. I even tried setting DateHeader as follows but no luck.
    res.setDateHeader("expires", System.currentTimeMillis()).
    thanks in advace

    And is this servlet actually sending the image itself, or it is sending some HTML that contains a link to the image? If it's the latter, then no amount of saying not to cache the HTML will have any effect on whether browsers cache the linked image.
    Actually now that I read your post more carefully, I see that you are sending HTML which presumably has an <img> tag referring to the image. The browser will download that image as a separate transaction. But if you change the date on the image file to something later, the browser should stop caching it.

  • Coherence Help standalone java program put data in cache & Servlet to Read

    Hi,
    I have coherence 3.4 and using Oracle Application Server 10.1.3 We are in the process of developing a Web Application and want to use Coherence for caching the data. My Coherence is also installed on the same box as Oracle Application Server 10.1.3 need some help in storing the data in the coherence and reading it through the servlet. We have standalone java program that needs to put data in the cache and through servlet want to read that and display it on the page. When running the client the data is stored in the cache but when reading it through the servlet it returns null. We have included both coherence.jar and tangosol.jar in the war file and also in the path when running the standalone java program. Started the Coherence using the below command:
    C:\oracle\coherence\lib>java -cp coherence.jar -Dtangosol.coherence.cacheconfig=C:/oracle/coherence/tests/cache-config.xml com.tangosol.net.DefaultCacheServer
    here is the sample config file used when starting the server above:
    <?xml version="1.0"?>
    <!DOCTYPE cache-config SYSTEM "cache-config.dtd">
    <cache-config>
        <caching-scheme-mapping>
            <cache-mapping>
                <cache-name>VirtualCache</cache-name>
                <scheme-name>default-distributed</scheme-name>
            </cache-mapping>
        </caching-scheme-mapping>
        <caching-schemes>
            <!--
            Default Distributed caching scheme.
            -->
            <distributed-scheme>
                <scheme-name>default-distributed</scheme-name>
                <service-name>DistributedCache</service-name>
                <backing-map-scheme>
                    <class-scheme>
                        <scheme-ref>default-backing-map</scheme-ref>
                    </class-scheme>
                </backing-map-scheme>
            </distributed-scheme>
      <class-scheme>
                <scheme-name>default-backing-map</scheme-name>
                <class-name>com.tangosol.util.SafeHashMap</class-name>
                </class-scheme>
    </caching-schemes>
    </cache-config>And here is the standalone java program to put the data in the cache:
    import com.tangosol.net.CacheFactory;
    import com.tangosol.net.NamedCache;
    public class PutCache {
        public PutCache() {
        public static void main(String[] args) {
            PutCache putCache = new PutCache();
            NamedCache         cache = CacheFactory.getCache("VirtualCache");
            String key = "hello";
            cache.put(key, "Hello Cache123123");
    }And here is the Servlet code to read the data but it somehow returns null
    import com.tangosol.net.CacheFactory;
    import com.tangosol.net.NamedCache;
    import java.io.IOException;
    import java.io.PrintWriter;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class Servlet1 extends HttpServlet {
        private static final String CONTENT_TYPE = "text/html; charset=windows-1252";
        public void init(ServletConfig config) throws ServletException {
            super.init(config);
        public void doGet(HttpServletRequest request,
                          HttpServletResponse response) throws ServletException, IOException {response.setContentType(CONTENT_TYPE);
            PrintWriter out = response.getWriter();
            NamedCache         cache = CacheFactory.getCache("VirtualCache");
            String value = (String)cache.get("hello");
            out.println("<html>");
            out.println("<head><title>Servlet1</title></head>");
            out.println("<body>");
            out.println("<p>The servlet has received a GET. This is the reply.</p>"+value);
            out.println("</body></html>");
            out.close();
    }Is there any other configuration I need. Any help is really appreciated.
    Thanks

    Hi,
    While starting the coherence using
    C:\oracle\coherence\lib>java -cp coherence.jar -Dtangosol.coherence.cacheconfig=C:/oracle/coherence/tests/cache-config.xml com.tangosol.net.DefaultCacheServer
    while running standaone jave program using the below command
    java -Dtangosol.coherence.cacheconfig=C:/oracle/coherence/tests/cache-config.xml Populatecache
    In the Web Application don't have any reference to cache-config.xml just using the coherence.jar & tangosol.jar.
    What are the steps or configurations I need in order to connect to the same Coherence Cache. Do I need to provide some host:port for the Coherence for storing the data in the cache. How does the java client program and Web Application knows to connect to the Coherence. As currently even if I don't start the coherence server and just run the java standalone program it goes and executes fine wondering wher exactly does it persists the cache if coherence itself is not started or just adding the jars is enough. Any help is appreciated.
    Thanks

  • Cocoon or Servlet based XSL?

    I'm working on putting up a page to publish documents written in DocBook/XML. I have been trying to learn Cocoon well enough to do this, but it just seems so complicated I'm having a hard time making progress.
    Is there any conventional wisdom on whether it would be easier to do the Cocoon thing or just go ahead and do the necessary XSL transforms (and caching) using Servlets and JSPs? I noticed one of the Tag Libraries supports XSLT -- that must be what its for.
    Any hints, links, tips or admonishments would be welcome.

    As far as i know, Cocoon should do caching of the results of the transformation.
    In an XSL solution for large documents, caching is essential because XSL has heavy memory and CPU consumption.
    But more practically, you can see how well your application works without caching (the simplest solution). For this, you only need servlets, or JSTL. Then, if it's needed, apply the caching with a servlet, or by interposing a servlet filter.

  • Null values passed into the servlet

    Hi all,
    I keep getting null values for all the params that I pass into the servlet i.e. sqltype, producttype, process, instance etc....I have attempted to print some of them out on the screen but I keep getting the 'NullPointerException' error message...can anyone tell me what it is that I have down wrong in the below code?
    If I run the servlet with method calls that have hardcoded arguments in them it works but not when I pass in the params from the URL...I am absolutley puzzled!
    Help!
    package blotter;
    import java.io.IOException;
    import java.io.PrintWriter;
    import java.util.Date;
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import com.db.util.WriteToLogFile;
    import blotter.cache.*;
    Servlet to extract an object that has already been placed
    in the cache by GetBondPrices servlet from the cache.
    public class ExtractSecurityObject extends HttpServlet
         String sqlType = "";
         String productType = "";
         String instance = "";
         String process = "";
         String asOfDate = "";
         String currencyCode = "";
         String curveId = "";
         String results = "";
         private String debug;
    private PrintWriter out;
         private WriteToLogFile logFile;
         // called when servlet first initialised
         public void init(ServletConfig config) throws ServletException
              super.init(config);
         // method called for each get request
         public void doGet( HttpServletRequest request, HttpServletResponse response )
                   throws ServletException, IOException
              String toWrite = " ";
    // Get the object identifier from the parameters passed in
              sqlType = request.getParameter("sqltype");
    productType = request.getParameter("producttype").toUpperCase();
              instance = request.getParameter("instance");
              process = request.getParameter("process");
              asOfDate = request.getParameter("asofdate");
              curveId = request.getParameter("curveid");
              currencyCode = request.getParameter("ccy").toUpperCase();
              out.println(currencyCode);
              if ( request.getParameter("debug") !=null)
                   debug = request.getParameter("debug");
              else
                   debug ="";
              // set the mime type to html
    response.setContentType( "text/html" );
    out = response.getWriter();
    out.println("<HTML>");
              try
              // write some parameters to a log file
              toWrite = toWrite + "<li>" + getServletInfo() + " at " + new Date() + " " + sqlType + " " +
                        productType + " " + instance + " " + process + " " + asOfDate + " " + curveId + " " +
                        currencyCode;
         CachedObject o1 = (CachedObject)CacheManager.getCache("EB_" + currencyCode + productType + asOfDate);
    if(o1 == null){
              CacheSecurityObject cso = new CacheSecurityObject();
                   if((request.getParameter("sqltype") == null) && (request.getParameter("instance") != null)){
    results = (String)cso.putSecurityinCache(null, request.getParameter("producttype"), request.getParameter("instance"), request.getParameter("process"), request.getParameter("asOfDate"), request.getParameter("curveId"), request.getParameter("currencyCode"));
    //results = (String)cso.putSecurityinCache(null, "yc", "frafu", "official", "20011105", "baceod", "sek");
    out.println(results);
                   } else {
    //results = (String)cso.putSecurityinCache("bondtypes", "bond", null, "official", "20011105", "baceod", "eur");
    results = (String)cso.putSecurityinCache(request.getParameter("sqltype"), request.getParameter("producttype"), null, request.getParameter("process"), request.getParameter("asOfDate"), request.getParameter("curveId"), request.getParameter("currencyCode"));
    out.println(results);
              else{
                   out.println(((String)o1.object).toString());
    // general catch for all exceptions
              catch(Exception exception)
                   out.println( "Exception: The item that you requested was not found in the cache" + "<BR>" );
                   toWrite = toWrite + "Exception : " + exception.getMessage() + "\n" ;
              finally
    // write to logfile
              logFile = new WriteToLogFile();
              logFile.setSourceDirName("blotter");
              logFile.setQuery(request.getQueryString());
              logFile.setServletPath(request.getServletPath());
              if (toWrite!=null)
              logFile.writeLog(getServletInfo(),toWrite);
    out.println("</HTML>");
              out.close();
         // need the class name for log file
         public String getServletInfo()
         return this.getClass().getName();
    }

    That section of the code references a cache to extract an item that has been requested by the user. If the item is not in the cache i.e. if(o1 == null) then it will call a class that generates that object and places that object into the cache. The second time the user makes the same call then they will be handed a cached copy of that object which is aimed to make the whole servlet call faster.
    That section of the code works fine coz I have tested that separately. It is the reading in of the arguments that is causing the problem.

  • Cache Invalidation using Invalidation Rule -not working

    Hi,
    I am caching a JSP using servlet caching by specifying it in the cachespec.xml. I am setting a dependency id for the cache entry and have also set an invalidation rule saying if the dependency id comes as a parameter for "xyz" then invalidate the cache. The jsp is getting cached, and the value that I specify as dependency id is also appearing. But when i try to invalidate it by passing the parameter say "http://localhost/wps/myportal/dynacache?xyz=1234", the cache doesnt get invalidated.
    Please suggest as what is the issue with this approach? Why is the cache invalidation not happening as per the rule set? Is there any other approach to invalidate it other than TTL? I understand invalidation-generator can only be used for web-service client cache.
    Please reply ASAP..
    This is my cache entry
    <cache>
    <cache-entry>
    <class>servlet</class>
    <name>/_caching/jsp/html/CachingPortletView.jsp</name>
    <cache-id>
    <component id="Cached" type="attribute">
    <required>true</required>
    </component>
    <component id="locale" type="locale">
    <required>false</required>
    </component>
    <component id="" ignore-value="true" type="pathinfo">
    <required>false</required>
    </component>
    </cache-id>
    <dependency-id>test
    <component id="Cached" type="attribute">
    <required>true</required>
    </component>
    </dependency-id>
    <invalidation>test
    <component id="Cached" type="parameter">
    <required>true</required>
    </component>
    </invalidation>
    </cache-entry>
    </cache>
    Regards,
    Sariba

    This sounds like an application server specific configuration, which is off-topic here. Try a forum devoted to your application server.

  • Handling long XML strings in XSLT

    I am creating an XML string dynamically to feed to my XSLT processing servlet. In a prototype I did this by passing the XML as a string to a routing servlet that then calls HttpResponse.sendRedirect() with the name of the XSLT processing servlet and the XML string like this :
    redirectString = "/WardenConfig/servlet/XSLTServlet?xslPage=" + nextPage + "&xmlSourceString=" + XMLData ;
    where XMLData is the dynamically built XML and nextPage is an XSL stylesheet. Then I send use this to send it all to the servlet that processes the XSL and displays the result :
    response.sendRedirect( redirectString );
    The problem is that when I get a lot of data in the XML string this does not work. I think this might be because sendRedirect() uses the GET method but I am not sure. SO I had two questions :
    1) Is that the problem - the GET method, I mean ?
    2) What's a better way to do this ?
    thanks in advance !!

    Will do, Doctor. I appreciate your quick help ! Is that the way most people handle this ?
    By the way, if you can tell me how to award Duke Dollars, I would like to do that. For some reason I can't do it anymore .. used to be able to ... feel lame ...
    Thanks again.

Maybe you are looking for

  • How to get FindAgain & FindPrevious from javascript OR other options

    Hi All, I'm trying to use the 'SearchResults -> Next Hit [Old]     'SearchSubmenu -> FindAgain' [New] Out of all these: Find | FindSearch | SearchSubmenu | FindAgain | FindPrevious Only 'Find' and 'FindSearch' works from javascript - None of others w

  • How can I prevent Firefox from ever automatically updating without my say so. It just did, and DESTROYED all bookmarks. I'm BUMMED about that

    There were NO .json files saved anywhere in the 'puter. I need to be reliably OPTED OUT of automatic updating unless the auto destruction forces warn me aforehand to backup my cookies, bookmarks, email and etc. When I now click on Help, I get an auto

  • Can't access login page in IE

    Hi, Some of my participants/customers, from the same organization, can't access the login page when they are going to participate in a meeting. They can access the login screen for Connect Pro Central but not for the meeting. For example the can acce

  • Yahoo health does not display tiles anymore

    Until yesterday, yahoo health and other yahoo links would display tiles of photos which were links to other articles. As you I would scroll down, other tiles would appear (still does in IE). Now there are no tiles at the bottom of the page.

  • Customs Declaration Cancellation

    HI - GTS System is configured to create a Customs Declaration Document automatically upon saving the Billing Document in SAP ECC System         What is the process followed in the below scenarios:         1) Billing Document has to be cancelled out i