File Caching in JSP

Hi,
I view a bunch of PDF's in my JSP file which can then be modified according to the user needs. For example, the user views a PDF file, then he/she can remove some documents within the pdf which will contact a Bean, remove the documents, recreate the PDF and save it with the same path and name. However, when I try to view the file, it still displays the old one although the new file gets created successfully when I check in my directory... any inputs on how I can avoid this problem?
THanks,
YAsir

I am using the following code to disable cache,. is that any different from the one you sent?
I think its more of a "PDF file opening up in a browser" kinda problem
thanks though
<%
response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
%>

Similar Messages

  • Valiable file name in JSP include

    Hi,
    I am trying to include a html file in a JSP page. The filename comes from the properties file and hence is a variable. The JSP file that has this include does not cache the JSP page plus it "refreshes" (reloads) ever 30 seconds.
    When I include the HTML file using jsp:include I am not getting the HTML file on alternate browser refreshes. Wierd?
    I then hard coded the filename and included the html file using <% @ include... and it works just fine.
    But I cannot have a variable name in <%@ include.
    Please comment on this wierd behaviour of jsp:include and gimme a solution.
    Thank you all in advance,
    Ravi Mittal

    Sorry this isn't a solution, because I have the very same problem and was just getting ready to post a question when I saw your post. I have also tried using:
    <jsp:include page="<%= myFilename %>" flush="true" />
    as well as
    <%@ include file="<%= myFilename %>" %>
    Neither of these work. This kind of approach seems to work just fine using <jsp:forward....>, but there's something funny about trying to include a file dynamically.
    I would also appreciate a solution. Good luck.
    - Joe

  • Control client cache for JSP

    There are many threads on the web about how to force a reload rather than pulling content from cache. My problem is the opposite. I am trying to get good cache control for a jsp application that has relatively static contents. My goal is to serve up pages with the following characteristics:
    For client calls:
    If there is no version in cache, the jsp builds a new version and sets the response date header "Expires" to 5 days later.
    If within the Expires date, have the client just use the cached version: no validation or roundtripping.
    If after the Expires date, roundtrip: have the jsp return 303 (SC_NOT_MODIFIED) if no content changed. Also, ideally, also reset the Exipres date to an additional 5 days.
    Otherwise, recreate the response and start over...
    I am experiencing different behaviors with different browsers, although none act as I was hoping.
    When there is no relevant page in cache, all of the browsers accept a new version (and I think that they all put it in cache). All browsers reload the page using the reload button.
    If there is a relevant page in cache and it has not expired:
    1. FireFox 3 seems to roundtrip, but then use the version in cache.
    2. IE 7 seems to always use the cache version without checking the server
    3. Google Chrome seems to always roundtrip and reload.
    I tried several variations including setting/not setting the Last-Modified date header and setting/not Cache-Control: no-control header (to force validation).
    Neither Last-Modified nor no-contro: NO CHANGE FROM ABOVE;
    Last-Modified set, no-control not specified: NO CHANGE
    Last-Modified not set, Cache-Control set to no-control to force validation.
    The main problem here is that I was unable to get a value for the request header "Last-Modifier" so that my jsp could not set the 303 return, therefore all browsers roundtrip and reload.
    SO...
    1. What do I need to do to get all browsers to pull from cache and not roundtrip prior to the Expires date?
    2. After the Expires date, what do I need to do to get the request to include the Last-Modified date header sent to the server?
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><%
    %><%@ page import="java.net.*"%><%
    %><%@ page import="java.util.*"%><%
    %><%@ page import="java.util.Date"%><%
    %><%@ page import="javax.servlet.*"%><%
    %><%@ page import="java.text.SimpleDateFormat" %><%
    //  In a real application, the updatedDate would come from a database or file
    Calendar thisCal = new GregorianCalendar();
    thisCal.set(2009,02,15);
    Date     updateDate = thisCal.getTime();
    //  This never returns a valid date
    long  thisLongDate  = request.getDateHeader("Last-Modified");
    Date  cachedDate    = ((thisLongDate<0)?null:new Date(thisLongDate));
    Date  todaysDate    = new Date();
    //  Show all three dates in the output
    String   outString = "";
    SimpleDateFormat   showDateFormatter = new SimpleDateFormat ("yyyy-MM-dd hh:mm:ss");
    outString += "================================================================<br> \n";
    outString += " Start TestSuite25.jsp "+showDateFormatter.format(todaysDate)+"<br> \n";
    outString += "Update date is "+showDateFormatter.format(updateDate)+"<br> \n";
    outString += "Cached date is "+((cachedDate==null)?null:showDateFormatter.format(cachedDate))+"<br> \n";
    response.setContentType("text/html");
    if (request.getParameter("lastmodified") != null)
       outString += "Set Last Modified header:  may trigger If-Modified-Since request. <br> \n";
       response.setDateHeader("Last-Modified",updateDate.getTime());
    //  force validation .. does this hit my code??
    if (request.getParameter("cache") != null)
        outString += "Set cache control to no-cache to force validation on every call<br> \n";
        response.setHeader("Cache-Control", "no-cache");
    //  use cache for 5 days, then validate
    thisCal.setTime(todaysDate);
    thisCal.add(Calendar.DATE,5);
    response.setDateHeader("Expires", thisCal.getTime().getTime());
    //  Check for still fresh on server
    if (!(cachedDate == null) && (!cachedDate.before(updateDate)))
       outString += "Contents are unchanged: send 303 status message<br> \n";
       response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
       System.out.println(outString);
    else
       outString += "Rebuild and send the HTML <br>";
       System.out.println(outString);
       // Build and send the HTML ...
    %>
    <html>
    <head>
      <title>Test suite</title>
      <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
    </head>
    <body >
    <br>
    <h2 align="center">Test 25: Controlling Cache</h2>
    <h3 align="center">Click <a href="TestSuite21.html">here</a> to continue to Test 26.</h3>
    useage: TestSuite25.jsp<br>
    optional parameters: <br>
       cache=nocache: include no-cache to force validation each time<br>
       lastmodify=set:  include Last-Modified date hearer<br>
    <br>
    <%=outString%>
    </html>
    </body>
    <% } %>

    let me tell you from BSP side !
    within your BSP application set a javascript timer for 2 minutes and upon completion run a javascript to kill the backend session along with the SSO2 cookie.
    check the BSP application system/session_single_frame.htm
    for a javascript named "exitBSPApplication"
    Hope this is helpful.
    Regards
    Raja

  • Cache  Problem-JSP

    Hi All,
    I am developing a web application using JSP and Flash
    In Flash i had given links for various countries
    Once the user clicked the link session for language
    and country is set..
    since v have only five links i call separate jsp file for
    each click
    this works fine for some time
    but some time it won't
    i checked each time..
    And found the problem is b'ze of tht history in IE[cache]
    Is there any way to clear tht cache using JSP or by any way thru coding
    I used out.clear(),out.clearBuffer() and all it won't worked
    out
    Hope number of ppls r there to help
    expecting a quick reply
    make a mail to me at
    [email protected]
    Friendly
    Arul

    Set the following scriptlet on every page...
    <%
    response.setHeader("Cache","NoClear");
    response.setHeader("Pragma","NoClear");
    response.setDateHeader("Expires",0);
    %>

  • How to upload data into a database from a csv file in a jsp app?

    I can write a HTML form to let users to post a csv file and store it in the web server, then how could I process the file to load the data into a View Obj or an Entity Obj without manually parsing the csv files? Any jsp or java code samples that will do something like the "sqlload" in sqlplus?
    I'm using JDev 3.1.1.2. Thanks.

    Navy_Coder wrote:
    6 zebras.But you must marry his eldest daughter as well, for that dowry.

  • How to call a class file in a jsp without deploying anything in j2ee

    Hi,
    I am new in J2EE. I have some jsps, which I configured using web.properties(documentroot=c:/jsp/). I am able to get
    those pages by the web browser. I have some import statements in some jsps, now I
    am trying to access those page but it is failing, it says
    org.apache.jasper.JasperException: Unable to compile class for
    JSPD:\j2sdkee1.3\repository\pradip\web\_0002fLogin_0002ejspLogin_jsp_0.java:1:
    Class com.gui.UPMGuiGlobalConstants not found in import.
    import com.gui.UPMGuiGlobalConstants;
    Actually I have not deployed any class file or jsps.. Now my question is can I access
    these jsps without deploying anything, like can I put my .jar file in any j2ee
    directory(like lib or anywhere else, I already tried after putting in /lib) and restart the
    j2ee and use it. So how can I call a class file from a jsp without any kind of
    deployment?
    Please send me the reply as soon as possible.
    Regds,
    Pradip

    After you put the jar containing the class to import into the WEB-INF/lib directory, you still need to include it in the jsp.
    Putting the jar into the lib dir, will make it available to the vm, but as in any other java class, you still need to import it into the class, that the jsp will be compiled into.
    And you do that by putting
    <%@page import="com.gui.UPMGuiGlobalConstants" %>somewhere near the top of your jsp. (well you don't need to put it there, but it good style ;)
    That should do it.

  • How to convert JSP Compiled class file back to JSP

    Is their any way to convert the JSP converted class file back into JSP file, I have few JSP files missing in my application but i do have class files deployed corresponding to the JSP file. Is their any way where i can convert my JSP class file back to JSP. I tried used decompliers but it conerts the class file into JAVA files, Is their any such decompiler that converts the JSP converted class file into Java files.
    Thanks in Advance.

    nope...its not et al possible...!!!
    You cant convert class file back to JSP....!!

  • How to write to a log file within a JSP

    Hello everybody,
    do you know how to write to a log file within a JSP.
    my code is (/space/SP/tlf/ExcepcionJava.jsp):
    <html>
    <body bgColor=#C4E1FF>
    <%@ page import="java.io.*" %>
    <%
         FileWriter salida = new FileWriter(response.encodeURL("log.txt"));
         salida.write(request.getParameter("errorMsg"));
         salida.close();
    %>
    </body>
    </html>.. I run under Solaris, Jrun 2.3.3
    I have also test with getServletContext().getRealPath(), but I get /netsrv/nes/docs/ instead of /space/SP/tlf/

    Hi,
    Give the full path of the log file to the FileWriter. Such as;
    FileWriter salida = new FileWriter(response.encodeURL("/usr/local/tomcat/logs/testlogs/log.txt"));
    nurettin

  • How to Generate a Java file for a JSP Page

    Hi ,
    I am using weblogic11 .
    I am working on a JSP page which nearly consists of 4000 lines of code.
    I need to debug the file , but weblogic server is not generating the java file for the JSP pages .
    Please let me know how can i genertae Java file for the jsp pages ??

    JSPs are compiled into servlets automatically and those classes are stored in WEB-INF/classes folder. Servlet engine handles servlets.

  • How to include a .class file in a jsp page

    hi everyone,
    i know the syntax as:
    <%@ include file = "filename.class" %>
    then at run time the server could not find the class file
    if i use,
    <%@ page import = "FileName.class" %>
    then also the same problem persists
    & if i use
    <jsp:include page = "Relative address"/>
    the problem still remains as it is...
    please help me out...i am working on developing an EJB application in which client interacts with server's Stateful session bean through a jsp page...it is necessary for me to include the home interface class file in my jsp page.
    P.S. do not suggest me to include the class file in a package & then use
    <%@ page import = "packageName.ClassFileName" %>
    i
    Edited by: Ankit_JIITU on 6 Jul, 2008 1:55 AM

    Ankit_JIITU wrote:
    i have already included the remote interface class file by <%@ page import = "University.RemoteInterfaceName" %>in my jsp page ...
    if i try to make a new package called test & then include my home interface in that package...i need to import University.*to generate the class file of my home interface ; but the class file generation is not taking place as i am getting the error..
    "package University does not exist".How can i overcome this problem. The package University, which you are trying to import, must be in the classpath. If you removed it then you will have to add it back.
    i have tried my best..but tell me if there's any possible way of including a class file in the jsp page without involving a package.No, there isn't.
    If not,then pls help me to generate the class file of my home interface within a package called test.Read the New To Java Tutorial and understand how packages work.
    >
    i am assuming that u have a deep knowledge of developing EJB applications.

  • Uploading a file in a jsp page

    Hii Javaites
    I am developing an application in which i need to upload file from a jsp page, right now i am using tomcat can anyone tell me the code for uploading a file.
    Thanking in Advance

    Hi,
    For uploading file from jsp:
    1) Goto javazoom.com, then download latest version for upload the files.
    2) Extract the zip & thay giving four jar files
    they are:
    i)uploadbean.jar
    ii)struts.jar
    iii)fileupload.jar
    iv)cos.jar
    put all this jar in lib of u r web application
    ex:
    C:\jakarta-tomcat-5.0.25\webapps\URWEBAPP\WEB-INF\lib\
    3) Set it in class path
    4) create one jsp with file option<input type='file' name = 'somename'>
    5) In action page(next page)
    <%@ page language="java" import="javazoom.upload.*,java.util.*" %>
    <%@ page errorPage="error.jsp" %>
    <jsp:useBean id="upBean" scope="page" class="javazoom.upload.UploadBean" >
    <jsp:setProperty name="upBean" property="folderstore" value="c:/uploads" />
    </jsp:useBean>
    Set the folder where u want upload the particular file.
    MultipartFormDataRequest mrequest = new MultipartFormDataRequest(request);
    Hashtable files = mrequest.getFiles();
         UploadFile file = (UploadFile) files.get("somename");//Give name u r given in the previous page.
         String fileName = file.getFileName();     
    upBean.store(mrequest, "userFile");
    follow this steps it works fine.
    regards
    DRA

  • Urgent : Executing a batch file in a JSP file

    Hi;
    I need help in executing a batch file within a jsp page, ive the following codes but it doesnt seem to work...
    These are the codes :
    <%@ page import="java.util.*,java.io.*,java.net.*" %>
    <%@ page import="java.sql.*" %>
    <%
    Process p = Runtime.getRuntime().exec("Ratio.bat");
    p.waitFor();
    int i = p.exitValue();
    %>
    The following is the error :
    ype Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    java.io.IOException: CreateProcess: Ratio.bat error=2
    java.lang.Win32Process.create(Native Method)
    java.lang.Win32Process.<init>(Win32Process.java:63)
    java.lang.Runtime.execInternal(Native Method)
    java.lang.Runtime.exec(Runtime.java:550)
    java.lang.Runtime.exec(Runtime.java:416)
    java.lang.Runtime.exec(Runtime.java:358)
    java.lang.Runtime.exec(Runtime.java:322)
    org.apache.jsp.invRatio_jsp._jspService(invRatio_jsp.java:52)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    Anyone can tell me why it doesnt work ?... Thanks

    Aside from removing the "start" or adding the title ...
    Does your batfile really say "SET PATH=%PATH%;%JAVA_HMOE%\bin"? If so, I rather expect you meant to say "JAVA_HOME" and not "JAVA_HMOE".
    Also, I'd be cautious about those relative paths that you're passing in to the Java program. Of course I don't know what you're doing with those in the program, but if you try to just pass those paths to a File or InputStream constructor, they're going to be relative to the current directory. And if you execute a batfile using cmd from an exec that's within a JSP ... I'm not sure what your current directory would be when the bat runs. Maybe you've checked this out and it's the right place, but if not, perhaps you have a misconception there.

  • How to Move Offline Files Cache in Windows 7?

    I'm using the offline files feature in Win7 (much better implementation, btw - kudos!) and I've run into a problem:  the CSC is using up all the drive space on C:\.  I'd like to move the CSC to D:\, however I've been unable to do so.
    I've seen this posted here previously (2/2009), however the response was to follow the instructions from Vista (using migwiz.exe).  When I launch migwiz.exe, I have no option of selecting the offline files as outlined in the Vista instructions (http://blogs.technet.com/filecab/archive/2006/12/12/moving-the-offline-files-cache-in-windows-vista.aspx).
    Are there any other ways of doing this?
    Thanks!

    Hi everyone,
    I have found a way to move the offline cache in W7, but it means you have to reset your existing offline files, give the new location, and resync the folders in the new location.
    Here is what to do (if you haven't synchronised any offline files yet, for exemple after a clean install, you can start directly in step 3):
    0) Make sure your existing offline files are synchronised with the server, as you are going to lose ALL the offline copies and you don't want to lose any new/modified files. Make a backup if you're not sure and if the files are important.
    1) reset the content of the old cache by adding the following command in a batch file and running it (of course you can add the parameter in the registry manually, but it's quite handy to have the batch ready whenever you need to reset the cache):
    REG ADD "HKLM\System\CurrentControlSet\Services\CSC\Parameters" /v FormatDatabase /t REG_DWORD /d 1 /f
    2) Reboot, the added key will be detected, all the content of the cache will be deleted, as well as the key itself (it only resets once)
    3) Add the following registry key in the same HKLM\System\CurrentControlSet\Services\CSC\Parameters section of the registry:
    Type: REG SZ (string)
    Name: CacheLocation
    Value: the new location in NT format, ie \??\d:\csc if you want to create the new cache in d:\csc
    4) Create the folder in the new location
    5) Reboot (not sure if it's necessary, but better safe than sorry)
    6) Reselect the files/folders you want to sync offline, and they should sync in the new location.
    7) If you want to, you can delete the old cache location in c:\windows\csc by following the end of the vista procedure linked in the first post (using takeown etc)
    It worked for me (Win7 RTM x86), let us know if it works for you...
    Obviously it won't help if you don't want to / can't resynchronise, but if you're starting from scratch or don't mind resyncing from scratch, it's a good workaround.
    EDIT: if you sync a lot of files and get a lot of errors, try to reset your offline files again following the above procedure (steps 1-2), disable offline files, reboot, enable offline files, reboot, and resync your files. Again, it worked for me...

  • I used tag to show PDF file inside my JSP page, It is working properly in IE but nothing shows in Mozilla. What should I do?

    I've used to display a PDF file inside my JSP page. It is working fine in IE. However, many of users of this application are using Mozilla and the platform is Ubuntu so it is vital that the file is shown in Mozilla as well. How can I solve this problem.
    == This happened ==
    Every time Firefox opened
    == I run my jsp page

    Such conditional code will only work in IE and not in other browsers like Firefox.
    You can ask questions and advice about web development at the mozillaZine Web Development/Standards Evangelism forum.<br />
    A good place to ask questions and advice about web development is at the mozillaZine Web Development/Standards Evangelism forum.<br />
    The helpers at that forum are more knowledgeable about web development issues.<br />
    You need to register at the mozillaZine forum site in order to post at that forum.<br />
    See http://forums.mozillazine.org/viewforum.php?f=25

  • How can i include a file in my JSP

    hello i have one jst who need to use an instance of a class called Part I need to include that file in my JSP but How do i do that
    How do i import my Part.java class in my JSP ???

    At the top of your JSP:
    <%@ import="package.*, package.Class" %>or you could do this:
    <%jsp:useBean class="package.Class" id="CLASS" scope="page" />or you can use a servlet as an include and have it write HTML back to the JSP:
    <jsp:include page="MyServlet">
         <jsp:param name="PARAM1" value="data1"/>
         <jsp:param name="PARAM2" value="data2"/>
    </jsp:include>

Maybe you are looking for

  • Implementing SSL on TCP/IP

    I am trying to implement SSL on TCP/IP.I developed SSL Server and SSL Client,generated keystores and certificates for both server and client.For generating truststores both server and client need to exchange their certificates.Using self-signed certi

  • Datafile is Demange

    I have one problem, my tablespace is a offline, i have 8 datafiles, and 1 is MISSING00024 and not possibile recover this, and when I take the tablespace a online mode, is return a message: ALTER TABLESPACE GEN_DATA ONLINE ERROR at line 1: ORA-01157:

  • Adobe Reader for Windows Mobile 5

    When trying to install i keep getting a message on my phone that it cannot install because it is not digitally signed. HELP?

  • Song keeps repeating itself

    I just purchased a new iPod Touch. When playing my Purchased list the first song keeps repeating itself and I can't get the iPod to move onto the next song on the list. Read the online instruction manual and can't solve problem. Any suggestions out t

  • Numbers is exporting with strange characters

    I created a huge spreadsheet in Numbers 2.3, upgraded to Numbers 3.0. When I try to export to a CSV I get this strange charictor "Â" where there is supposed to be a space.  I have tried exporting differnet CSV version.  The problem is not uniform thr