Re: Java1.5 to 1.6
Great - thanks for that Chris - I found the problem and its all working now. On Wed, Jun 18, 2008 at 11:31 AM, Christopher Schultz < [EMAIL PROTECTED]> wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > Kimberly, > > Kimberly Begley wrote: > | I understand that the java executables should work properly but by the > looks > | of the error the problem might be with the servlet engines - would a > | recompile of the entire app be in order? any suggestions? > > [snip] > > | java.lang.NullPointerException > | org.apache.jsp.web.proceed_jsp._jspService(proceed_jsp.java:139) > > This is an error occurring in your "proceed.jsp" file. You should look > at the file proceed_jsp.java in TC's work directory and see what is on > line 139 of that file -- you should be able to figure out where that > maps to in your original JSP and see what might be null. > > Perhaps previous versions of TC had an object available in the > application/JNDI/session/request/page that is no longer there. More > likely is that certain configurations changed between versions and that > an object you expected to be properly loaded is not being loaded. > > An inspection of your JSP and the generated java source will help a lot. > > - -chris > > -BEGIN PGP SIGNATURE- > Version: GnuPG v1.4.9 (MingW32) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iEYEARECAAYFAkhYZYsACgkQ9CaO5/Lv0PDMFACcCztcgGOtt2MzVDupDi9CAq+z > jq4AoJqVWNFga0RLArO7XM/jLUr4ja2p > =f55b > -END PGP SIGNATURE- > > - > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Kimberly Begley
Java1.5 to 1.6
Hi, I have a web application that was working great with Tomcat 5 and Java 1.5 - the server has recently been upgraded to Java 6 (still with tomcat 5) and now some parts are not working and throwing null exceptions as pasted below. I understand that the java executables should work properly but by the looks of the error the problem might be with the servlet engines - would a recompile of the entire app be in order? any suggestions? Thanks Kim *description* *The server encountered an internal error () that prevented it from fulfilling this request.* *exception* org.apache.jasper.JasperException org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:476) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:389) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) *root cause* java.lang.NullPointerException org.apache.jsp.web.proceed_jsp._jspService(proceed_jsp.java:139) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) -- Kimberly Begley
Re: jsp session values - setting and getting problems
Great - thanks! On Wed, May 28, 2008 at 5:14 PM, Pid <[EMAIL PROTECTED]> wrote: > Kimberly Begley wrote: > >> Hi, >> The starting point of the app is the user uploading a zip file the file is >> processed and a summary of the results displayed (in the form I spoke of). >> >> It's basically a form that doesn't have any parameters but displays a >> button >> that goes to the report.jsp page when pushed (at least on my local system) >> The report.jsp page is supposed to get the array, and 2 vectors from the >> form page and print out further details in a report format. >> >> By putting in a few statement I found out the report.jsp is returning true >> to the session.isNew() function - I suppose that's why it can't see the >> variables. The session timeout is set to 1800 seconds. >> >> I have not been using URL rewriting and assumed it was using cookies but I >> have not set up anything to make this explicit -sounds like this might be >> my >> problem - can you point me to some documentation that I could refer to? >> > > " method="post"> > > Encode the 'href' in all links and form 'actions' to ensure your requests > are all linked to a single session. > > p > > > There is no user login - it's basically upload a zip file and it processes >> it and displays your results if your zip file contents are in the correct >> format. >> Thanks! >> Kimberly >> >> On Wed, May 28, 2008 at 1:18 PM, Christopher Schultz < >> [EMAIL PROTECTED]> wrote: >> >> Kimberly, >> >> >> Kimberly Begley wrote: >> | Hi, >> | I have a jsp form that sets session attributes as such: >> | session.setAttribute("totals",totals); >> | session.setAttribute("failures",failures); >> | session.setAttribute("skips",skips); >> | >> | and then the form directs to the report.jsp page as follows: >> | >> | >> | where the values are supposed to be retrieved like this: >> | >> | String[] totals = (String[])session.getAttribute("totals"); >> | Vector failures = >> (Vector)session.getAttribute("failures"); >> | Vector skips = (Vector)session.getAttribute("skips"); >> | >> | >> | I have tried using getAttribute, setAtrribute as well as setValue, >> getValue >> | --- the setValue, getValue work fine from my local copy but when moved >> onto >> | a server with the same linux version and tomcat version (5 that is) it >> is >> | returning null values for the 3 variables. >> >> FYI getValue and setValue should be mapped to getAttribute and >> setAttribute (with the latter being the preferred form). >> >> This really has nothing to do with the form, right? You just have data >> in the session and you want to pull it out someplace. >> >> Are you using cookie-based session-id-passing or url-rewriting. >> >> -chris >> >> >>> - > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >> >>> >>> > > - > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Kimberly Begley
Re: jsp session values - setting and getting problems
Hi, The starting point of the app is the user uploading a zip file the file is processed and a summary of the results displayed (in the form I spoke of). It's basically a form that doesn't have any parameters but displays a button that goes to the report.jsp page when pushed (at least on my local system) The report.jsp page is supposed to get the array, and 2 vectors from the form page and print out further details in a report format. By putting in a few statement I found out the report.jsp is returning true to the session.isNew() function - I suppose that's why it can't see the variables. The session timeout is set to 1800 seconds. I have not been using URL rewriting and assumed it was using cookies but I have not set up anything to make this explicit -sounds like this might be my problem - can you point me to some documentation that I could refer to? There is no user login - it's basically upload a zip file and it processes it and displays your results if your zip file contents are in the correct format. Thanks! Kimberly On Wed, May 28, 2008 at 1:18 PM, Christopher Schultz < [EMAIL PROTECTED]> wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > Kimberly, > > > Kimberly Begley wrote: > | Hi, > | I have a jsp form that sets session attributes as such: > | session.setAttribute("totals",totals); > | session.setAttribute("failures",failures); > | session.setAttribute("skips",skips); > | > | and then the form directs to the report.jsp page as follows: > | > | > | where the values are supposed to be retrieved like this: > | > | String[] totals = (String[])session.getAttribute("totals"); > | Vector failures = > (Vector)session.getAttribute("failures"); > | Vector skips = (Vector)session.getAttribute("skips"); > | > | > | I have tried using getAttribute, setAtrribute as well as setValue, > getValue > | --- the setValue, getValue work fine from my local copy but when moved > onto > | a server with the same linux version and tomcat version (5 that is) it is > | returning null values for the 3 variables. > > FYI getValue and setValue should be mapped to getAttribute and > setAttribute (with the latter being the preferred form). > > This really has nothing to do with the form, right? You just have data > in the session and you want to pull it out someplace. > > Are you using cookie-based session-id-passing or url-rewriting. > > - -chris > > -BEGIN PGP SIGNATURE- > Version: GnuPG v1.4.9 (MingW32) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iEYEARECAAYFAkg8zwIACgkQ9CaO5/Lv0PBaeACcCivFvzaEN0yRIWLq3swazgaA > J10AnjmNPASWyl7jLZuXkG4qHh2jixfL > =rlvC > -END PGP SIGNATURE- > > - > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Kimberly Begley
jsp session values - setting and getting problems
Hi, I have a jsp form that sets session attributes as such: session.setAttribute("totals",totals); session.setAttribute("failures",failures); session.setAttribute("skips",skips); and then the form directs to the report.jsp page as follows: where the values are supposed to be retrieved like this: String[] totals = (String[])session.getAttribute("totals"); Vector failures = (Vector)session.getAttribute("failures"); Vector skips = (Vector)session.getAttribute("skips"); I have tried using getAttribute, setAtrribute as well as setValue, getValue --- the setValue, getValue work fine from my local copy but when moved onto a server with the same linux version and tomcat version (5 that is) it is returning null values for the 3 variables. Any ideas? Thanks, Kimberly
session info
Hello - I'm using tomcat 5 and was wondering how session info is stored - is it stored server side in memory? Can anyone point me to some documentation about this? Thanks, Kimberly
jsp and servlet to present zip file for download
Hi, I'm stumped and was hoping someone might be able to point me in the right direction. I have an html page form that contains a series of checkboxes and radio buttons the form directs to a jsp page that processes the user's selections to determine which files to zip up for the user to download. I have written a servlet to do the zipping up of subdirectories according to the user's selections however I think that I am not calling it correctly. When the user hits the submit button - the resulting page is blank and the local_host log says this: org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service() for servlet jsp threw exception java.lang.IllegalStateException: getOutputStream() has already been called for this response The excerpt from the jsp file where the zip servlet is called is pasted below along with the zipservlet - any suggestions? Thanks! from jsp: request.setAttribute("tcases",cases); request.setAttribute("path",testdir); RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/servlet/ZipServlet"); dispatcher.include(request,response); zipservlet.java: public class ZipServlet extends HttpServlet { /** * Processes requests for both HTTP GET and POST methods. * @param request servlet request * @param response servlet response */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("application/zip"); response.setHeader("Content-disposition", "attachment; filename=selectedCases.zip"); try { ZipOutputStream zipOutputStream = new ZipOutputStream(response.getOutputStream()); Vector cases = findCases(request); String testpath = findPath(request); for(Iterator it = cases.iterator();it.hasNext();) { File tcase = new File(testpath + it.next()); addFilesToZip(tcase, File.separator, zipOutputStream); } zipOutputStream.flush(); zipOutputStream.close(); } catch (Exception e) { } finally { } } protected Vector findCases(HttpServletRequest request) throws IOException { Vector cases = (Vector)request.getAttribute("tcases"); return cases; } protected String findPath(HttpServletRequest request) throws IOException { String path = request.getParameter("path"); return path; } private void addFilesToZip(File path, String pathInZip, ZipOutputStream zipOutputStream) { if (path.exists()) { File[] files = path.listFiles(); for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { addFilesToZip(files[i], pathInZip + files[i].getName() + File.separator, zipOutputStream); } else { try { FileInputStream in = new FileInputStream(files[i]); zipOutputStream.putNextEntry(new ZipEntry(pathInZip + files[i].getName())); byte buf[] = new byte[2048]; int len; while ((len = in.read(buf)) > 0) { zipOutputStream.write(buf, 0, len); } zipOutputStream.closeEntry(); in.close(); } catch (IOException e) { } } } } } /** * Handles the HTTP GET method. * @param request servlet request * @param response servlet response */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } /** * Handles the HTTP POST method. * @param request servlet request * @param response servlet response */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } /** * Returns a short description of the servlet. */ public String getServletInfo() { return "Short description"; } }
permissions to read/write files outside webapps directory?
Hi, I've just deployed my webapp on the remote server (tomcat5 and red hat linux) - everything is displaying properly but when the user uploads a file for processing it is failing - looking in the log files it appears that tomcat can't read or write files outside the webapps directory by these error messages: java.io.FileNotFoundException: /home/kimberly/test/cases/85/85-settings.txt(Permission denied) Permissions on this directory are readable by everyone and I thought tomcat would be able to write/read to the tomcat5/temp directory but that doesn't appear to be happening either. I want it to read 1000's of files from my home directory and when uploading files to write them to the temp file in /usr/share/tomcat5/temp/test. This works great on my local copy but isn't working on the remote server. So from what I gather online I need to edit the catalina.policies file to allow read/write access to the appropriate directories. Before I go messing around with the policies file for the first time I wanted to double check that this is appropriate as well as check the syntax. // Example policy file entry grant [signedBy ,] [codeBase ] { permission[ [, ]]; }; So syntax would be something like: grant codeBase "file:${catalina.home}/temp" permission java.io.FilePermission, "read,write"; grant codeBase "file:/home/kimberly/test/cases" permission.java.io.FilePermission, "read"; And then do I just restart tomcat? Please any advice would be greatly appreciated. Thanks!
Re: where to put config file in a webapp
very cool - yes sorry I never seem to give enough detailed info - thanks for reading my mind! you have my wants described very clearly! I will give it a go - thanks!! On Wed, Apr 2, 2008 at 10:08 PM, Peter Crowther <[EMAIL PROTECTED]> wrote: > > From: Kimberly Begley [mailto:[EMAIL PROTECTED] > > Great thanks - it's not actually in a servlet - just a java > > class of methods > > so I guess I could pull it out of the java class and put it > > into the servlet > > that is calling the method - if that makes sense - I was just > > hoping to avoid that. > > Can we be clear about what "it" is here? Lots of pronouns, no clarity > :-). > > If I read you correctly: > > 1. You have a Java class that reads a config file, presently from a > hard-coded location; > > 2. Other code within your webapp invokes methods on the Java class that > reads the config file in order to read configuration information; > > 3. You want the Java class to be sensitive to the webapp's location, so > that the class can read the file from a location within the webapp; > > 4. You don't want to put webapp-specific code into the Java class that > reads the config file. > > While you can't *quite* do both 3 and 4, the following approach might be > helpful: > > - Amend the class that reads the config file so that it can accept a > stream, possibly in a constructor or static method call - depends whether > you're instantiating the class. Read the config data, close the stream - > you don't want to hold a file stream open for longer than you have to! > > - In your servlet code, use Chuck's init parameter approach to obtain the > path to the config file. Open a stream using getResourceAsStream() and hand > that stream to the class that reads the config file. > > - If you still want your class that reads the config file to be usable in > non-webapps, re-code so that if the class hasn't been passed a stream by the > time the first config variable is requested, it loads from a default > location. > > This isolates your class for reading the config file from any servlet > dependencies (they're external) at the expense of a little more complexity. > >- Peter > > --------- > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Kimberly Begley
Re: where to put config file in a webapp
Great thanks - it's not actually in a servlet - just a java class of methods so I guess I could pull it out of the java class and put it into the servlet that is calling the method - if that makes sense - I was just hoping to avoid that. Thanks for the advice - much appreciated. On Wed, Apr 2, 2008 at 9:47 PM, Caldarale, Charles R < [EMAIL PROTECTED]> wrote: > > From: Kimberly Begley [mailto:[EMAIL PROTECTED] > > Subject: where to put config file in a webapp > > > > Currently it is in WEB-INF > > Normally, such a properties or config file would be placed in > WEB-INF/classes, and accessed via ServletContext.getResourceAsStream(). > > > I read online that I could put the entry in the web.xml file? > > See section 4 of the Servlet Spec, in particular the > ServletContext.getInitParameter() API, then look at the Tomcat doc for > where to set them: > http://tomcat.apache.org/tomcat-5.5-doc/config/context.html#Context%20Pa > rameters > > - Chuck > > > THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY > MATERIAL and is thus for use only by the intended recipient. If you > received this in error, please contact the sender and delete the e-mail > and its attachments from all computers. > > - > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Kimberly Begley
where to put config file in a webapp
Hi, I have a config file for a web application - currently the absolute path is specified in a java class that's method's are read by a servlet to get the info in the config file - I want to deploy the webapp on a remote server so I'd like to remove the absolute path to the file but can't seem to figure out where to put it so that the class can see it. Currently it is in WEB-INF and the java file that references it is in WEB-INF/src/java which is compiled using the -d ../../classes flag so the resulting class ends up in WEB-INF/classes/tester/test (being in the tester.test package) - I've tried different combinations and read online that I could put the entry in the web.xml file? but haven't been able to find what the syntax would be for that or how I would access it. I'm using tomcat5 on a linux box. Can anyone point me in the right direction? Thanks
Re: displaying an image from outside the webapps directory
Great - got it working! Thanks so much for that again! Kimberly On Tue, Apr 1, 2008 at 12:07 AM, Christopher Schultz < [EMAIL PROTECTED]> wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > Kimberly, > > Kimberly Begley wrote: > | I was hoping to use the jsp:include tag to include the snippet (no html > or > | body tags) - I tried with the same code that Chris sent to open a jpeg - > | thinking it might be the same solution for the html but have gotten an > | internal error at the jsp include line. > > The problem is that JSPs use HttpServletResponse.getWriter (because JSPs > are used to produce text output) while the servlet you write uses > HttpServletRequest.getOutputStream. The two are incompatible for the > same request, and getWriter has already been called, to getOutputStream > fails. > > You have a couple of options: > > * Write another version of OpenFile called OpenTextFile or whatever > * Modify OpenFile to try getOutputStream first, then getWriter > * Put a special flag in the request, and have OpenFile detect that flag > ~ to determine whether getWriter or getOutputStream should be called > > If you want to use Writers instead of Streams, you should probably open > your file using a Reader instead of a Stream as well. > > Hope that helps, > - -chris > > -BEGIN PGP SIGNATURE- > Version: GnuPG v1.4.8 (MingW32) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iEYEARECAAYFAkfw8D4ACgkQ9CaO5/Lv0PCzxwCfYMDYRCHCjLxo5bCmq+wiuvMG > 0JAAn3+hBtaGqJx6Oucn/ufDBos+G6bi > =pp7j > -END PGP SIGNATURE- > > - > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Kimberly Begley
Re: displaying an image from outside the webapps directory
Thanks for that I will check it out - I have switched gears and have been trying to get a c:import to work - now I get the error printed in the middle of the page saying that: The requested resource (/test/home/kimberly/Desktop/testhtmlfile1.html) is not available where test is the directory under webapps and the path that was passed to the import statement was just /home/kimberly/Desktop... Any ideas how to get it to stop prefixing the path with /test? Thanks! On Mon, Mar 31, 2008 at 3:13 PM, Vamsavardhana Reddy <[EMAIL PROTECTED]> wrote: > Have you considered using the allowLinking attribute (See > http://tomcat.apache.org/tomcat-6.0-doc/config/context.html) and creating > a > soft-link inside the webapp directory to the directory which is outside of > webapp? > > ++Vamsi > > On Fri, Mar 21, 2008 at 4:28 PM, Kimberly Begley <[EMAIL PROTECTED] > > > wrote: > > > Hi, > > I'm trying to make a jsp display a plot that is a jpeg in a directory > > outside the catalina_home directory - I do not have the option of > > putting it in the webapp directory (there's 1000's of them - my page > > will just display one of them as selected by the user - along with > > some other info) - how do I go about displaying it? > > Thanks > > > > - > > To start a new topic, e-mail: users@tomcat.apache.org > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > -- Kimberly Begley
Re: displaying an image from outside the webapps directory
Hi, Wasn't sure whether to start a new thread but my question is in regards to the previous code. As well as the jpeg I also have some html that I wanted to include in the same page - so the html snippet is in a directory outside of the webapps directory and when a user selects a link I'd like to include it in the web output. I was hoping to use the jsp:include tag to include the snippet (no html or body tags) - I tried with the same code that Chris sent to open a jpeg - thinking it might be the same solution for the html but have gotten an internal error at the jsp include line. The servlet works great with a jpeg. I've pasted the error below - I just want to check that it really would be along the same lines to include html in a jsp as it was to include an image (both being outside the webapps directory) Or am I way off base? Thanks java.lang.IllegalStateException org.apache.jasper.runtime.ServletResponseWrapperInclude.getOutputStream(ServletResponseWrapperInclude.java:63) sbml.test.OpenFile.sendFile(OpenFile.java:48) sbml.test.OpenFile.service(OpenFile.java:89) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:965) org.apache.jsp.web.testdetails_jsp._jspService(testdetails_jsp.java:163) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) Servlet: import java.io.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*; public class OpenFile extends HttpServlet { private static final int BUFFER_SIZE = 4096; protected File findFile(HttpServletRequest request) throws IOException { String plot = request.getParameter("plot"); File file = new File(plot); return file; } protected String getMimeType(HttpServletRequest request, File file) { ServletContext application = super.getServletConfig ().getServletContext(); return application.getMimeType(file.getName()); } protected void sendFile(File file, HttpServletResponse response) throws IOException { BufferedInputStream in = null; try { int count; byte[] buffer = new byte[BUFFER_SIZE]; in = new BufferedInputStream(new FileInputStream(file)); ServletOutputStream out = response.getOutputStream(); while(-1 != (count = in.read(buffer))) out.write(buffer, 0, count); out.flush(); } finally { if (in != null) { try { in.close(); } catch (IOException ioe) { System.err.println("IO exception caught"); } } } } public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { File file = findFile(request); if(null == file || !file.exists()) { response.sendError(HttpServletResponse.SC_NOT_FOUND); } else if(!file.canRead()) { response.sendError(HttpServletResponse.SC_FORBIDDEN); } else { response.setStatus(HttpServletResponse.SC_OK); response.setContentType(getMimeType(request, file)); response.setHeader("Content-Type",String.valueOf(file.length ())); response.setHeader("Content-Disposition","attachment; filename="+ file.getName()); sendFile(file, response); } } } On Tue, Mar 25, 2008 at 9:33 AM, Kimberly Begley <[EMAIL PROTECTED]> wrote: > Thanks so much!! > The image is coming up now! > So much appreciated! > Kimberly > > > On Tue, Mar 25, 2008 at 12:03 AM, Christopher Schultz > <[EMAIL PROTECTED]> wrote: > > -BEGIN PGP SIGNED MESSAGE- > > Hash: SHA1 > > > > Kimberly, > > > > > > Kimberly wrote: > > | I might have messed it up when getting it to compile - I was having > > | problems with the getMimeType method with messages like this: > > > > Oops. It looks like I gave you some bad code, too. > > > > > > | /usr/local/jdk1.5.0_14/bin/javac -d ../../classes/ OpenFile.java > > | OpenFile.java:35: cannot find symbol > > | symbol : method getServletContext() > > | location: interface javax.servlet.http.HttpServletRequest >
Re: deployment questions
Great thanks! and sorry about that its tomcat5. On Thu, Mar 27, 2008 at 1:06 PM, Caldarale, Charles R < [EMAIL PROTECTED]> wrote: > > From: Kimberly Begley [mailto:[EMAIL PROTECTED] > > Subject: deployment questions > > > > 1) make a war file of my web app directory > > Yes. > > > 2) add a context entry to the server.xml file on the remote > > server > > Unless you're deploying on an ancient version of Tomcat (you didn't > bother to tell us), definitely not. Your element belongs in > your webapp's META-INF/context.xml file, if you need one at all. Note > that path and docBase attributes are not allowed in elements > in this circumstance. Read the doc: > http://tomcat.apache.org/tomcat-6.0-doc/config/context.html > > > 3) copy the war file to the remote server tomcat/webapp directory > > That's usually webapps, not webapp. > > > 4) stop and start tomcat on the remote server > > Usually not necessary, unless autoDeploy is disabled. > > > But then what is the process to see it online? > > The name of the .war file is the name of the webapp, so you reference it > via a URL like: > http://[:port]/ > > If Tomcat on the remote host is configured to use port 80, you omit that > from the URL, of course. If the host has no DNS entry, use its IP > address. > > - Chuck > > > THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY > MATERIAL and is thus for use only by the intended recipient. If you > received this in error, please contact the sender and delete the e-mail > and its attachments from all computers. > > ----- > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Kimberly Begley
deployment questions
Hi, I've been devloping a web app on a virtual machine on my computer and I want to move it over to remote server. I understand that I 1) make a war file of my web app directory 2) add a context entry to the server.xml file on the remote server (Q1: where in the server.xml file do I add this entry - it is a fresh install and I do not see one there to start with) 3) copy the war file to the remote server tomcat/webapp directory 4) stop and start tomcat on the remote server Q2: But then what is the process to see it online? everything I've read online stops at this part - do I not have to make more modifications to see it at a URL other than localhost? Thanks
Re: displaying an image from outside the webapps directory
Thanks so much!! The image is coming up now! So much appreciated! Kimberly On Tue, Mar 25, 2008 at 12:03 AM, Christopher Schultz <[EMAIL PROTECTED]> wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > Kimberly, > > > Kimberly Begley wrote: > | I might have messed it up when getting it to compile - I was having > | problems with the getMimeType method with messages like this: > > Oops. It looks like I gave you some bad code, too. > > > | /usr/local/jdk1.5.0_14/bin/javac -d ../../classes/ OpenFile.java > | OpenFile.java:35: cannot find symbol > | symbol : method getServletContext() > | location: interface javax.servlet.http.HttpServletRequest > | ServletContext application = request.getServletContext(); > > Obviously, that should have been: > > ServletContext application = > ~ super.getServletConfix().getServletContext(); > > > | OpenFile.java:38: incompatible types > | found : java.lang.String > | required: java.io.File > | return application.getMimeType(file.getName()); > > And it looks like this should have been > > protected String getMimeType(HttpServletRequest request, File file) > > { > ~ // This is a reasonable default implementation. > ~ // Feel free to change it. > ~ ServletContext application = request.getServletContext(); > > ~ return application.getMimeType(file.getName()); > } > > ...which will also fix this problem: > > > | OpenFile.java:92: setContentType(java.lang.String) in > | javax.servlet.ServletResponse cannot be applied to (java.io.File) > | response.setContentType(getMimeType(request, file)); > > Try my fixes and see what happens. > > If the image does not appear, try using LiveHTTPHeaders or some other > tool to watch the HTTP request/response for the image and see what > status code is returned. Feel free to add debug logging statements to > the class to give yourself more information. > > > - -chris > -BEGIN PGP SIGNATURE- > Version: GnuPG v1.4.8 (MingW32) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iEYEARECAAYFAkfntJQACgkQ9CaO5/Lv0PBudwCgqOgUD3S9+GAePwQRAJpRNSHQ > NqgAoKuqx54kAqfzGaO+MbaWDMbySgCe > =yuDp > > > -END PGP SIGNATURE- > > ----- > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Kimberly Begley - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: displaying an image from outside the webapps directory
File file) > ~{ > ~// This is a reasonable default implementation. > ~// Feel free to change it. > ~ServletContext application = request.getServletContext(); > > ~return application.getMimeType(file.getName()); > ~} > > ~protected void sendFile(File file, HttpServletResponse response) > ~throws IOException > ~{ > BufferedInputStream in = null; > > ~try { > int count; > ~byte[] buffer = new byte[BUFFER_SIZE]; > > ~in = new BufferedInputStream(new FileInputStream(file)); > > ~ServletOutputStream out = response.getOutputStream(); > > ~while(-1 != (count = in.read(buffer))) > ~out.write(buffer, 0, count); > > ~out.flush(); > ~} > ~finally > ~{ > ~if (in != null) > ~{ > ~try { in.close(); } > ~catch (IOException ioe) { /* log an error! */ } > ~} > ~} > ~} > > ~public void service(HttpServletRequest request, > > ~HttpServletResponse response) > ~throws ServletException, IOException > ~{ > ~File file = findFile(request); > > ~if(null == file || !file.exists()) > ~{ > ~response.sendError(HttpServletResponse.SC_NOT_FOUND); > ~} > ~else if(!file.canRead()) > ~{ > ~// Feel free to send NOT_FOUND instead, if you don't want to > ~// give up potentially sensitive security information. > ~response.sendError(HttpServletResponse.SC_FORBIDDEN); > ~} > ~else > ~{ > ~response.setStatus(HttpServletResponse.SC_OK); > ~response.setContentType(getMimeType(request, file)); > ~response.setHeader("Content-Type", > ~ String.valueOf(file.length()); > > ~response.setHeader("Content-Disposition", > ~ "attachment; filename=" > ~ + file.getName()); > > ~sendFile(file, response); > ~} > ~} > } > > - -chris > > -BEGIN PGP SIGNATURE- > Version: GnuPG v1.4.8 (MingW32) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iEYEARECAAYFAkfjxWoACgkQ9CaO5/Lv0PBiFACeJuF3Gb91N5pwJlaWDFrVkksb > NhYAoKg9CtqkwNqmO2l0iA8+pPBzPM1d > =1LA6 > -END PGP SIGNATURE- > > > > - > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Kimberly Begley - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: displaying an image from outside the webapps directory
Wow - great - thanks for the fast response - I will try it out. Have a great weekend! Kimberly On Fri, Mar 21, 2008 at 9:12 PM, Lars Nielsen Lind <[EMAIL PROTECTED]> wrote: > Kimberly Begley skrev: > > > > Hi, > > I'm trying to make a jsp display a plot that is a jpeg in a directory > > outside the catalina_home directory - I do not have the option of > > putting it in the webapp directory (there's 1000's of them - my page > > will just display one of them as selected by the user - along with > > some other info) - how do I go about displaying it? > > Thanks > > > > - > > To start a new topic, e-mail: users@tomcat.apache.org > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > You can do that with a Servlet. Here are some sample code. Replace > content of <> with your own data. > > > > package ; > > import java.io.*; > import java.util.*; > > import javax.servlet.*; > import javax.servlet.http.*; > > public class OpenFile extends HttpServlet { > > private String documentHome = "."; > private String page = ""; > private String version = ""; > private String remotehost = ""; > private String remoteaddress = ""; > > protected File findFile(HttpServletRequest request) throws IOException { > File file = new File(); > > return file; > } > > protected void sendFile(File file, HttpServletResponse response) > throws IOException { > int c = 0; > FileInputStream fis = null; > > try { > ServletOutputStream sos = response.getOutputStream(); > fis = new FileInputStream(file); > > while ((c = fis.read()) != -1) { > sos.write(c); > } > > sos.flush(); > } finally { > if (fis != null) { > fis.close(); > } > } > } > > public void service(HttpServletRequest request, HttpServletResponse > response) throws ServletException, IOException { > ServletConfig config = getServletConfig(); > ServletContext application = config.getServletContext(); > File file = findFile(request); > > if (file == null) { > } else { > > > response.setContentType(application.getMimeType("application/" + > file.getName())); > response.setContentLength((int)file.length()); > response.setHeader("Content-Disposition", "attachment; > filename = " + file.getName()); > sendFile(file, response); > } > } > > } > > Hope that this is useful. > > regards, > > Lars Lind > > - > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Kimberly Begley - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
displaying an image from outside the webapps directory
Hi, I'm trying to make a jsp display a plot that is a jpeg in a directory outside the catalina_home directory - I do not have the option of putting it in the webapp directory (there's 1000's of them - my page will just display one of them as selected by the user - along with some other info) - how do I go about displaying it? Thanks - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
regarding post about servlet crashing tomcat
I have no idea what the problem was other than the servlet name I suppose but I copied the entire servlet - pasted it in another file with a new name and it works, created a new file with the old servlet name and pasted the new (same) code back in it and it still doesn't work (and crashes tomcat) - only difference is the filename. Thanks --
servlet crashing tomcat
tenerlifecycleE vent INFO: Failed shutdown of Apache Portable Runtime -- Kimberly Begley
Re: jsp calling a servlet (or at least that's the goal)
Oh thanks so much! That got rid of my 404 error - now I have a 405 to tackle though - glad to be done with the 404 though - I thought I had tried every combination but I guess not!! Thanks Kimberly On Wed, Mar 12, 2008 at 10:21 PM, David Smith <[EMAIL PROTECTED]> wrote: > Keep in mind it's the browser that calls the servlet, not really your > jsp and the browser knows nothing of tomcat contexts. Your > tag should have an action of "/test/servlet/UploadUnzipTest". In the > jsp, you can compute this as action="${pageContext.request.contextPath}/servlet/UploadUnzipTest" > enctype="multipart/form-data"> in jsp pages. > > --David > > Kimberly Begley wrote: > > it's in CATALINA_HOME/webapps/test > > > > On Wed, Mar 12, 2008 at 10:14 PM, Mark Thomas <[EMAIL PROTECTED]> wrote: > > > > > >> Kimberly Begley wrote: > >> > >>> and my jsp form calls it like this: > >>> >>> method=post> > >>> > >> What is the context path your app is deployed to? > >> > >> Mark > >> > >> > >> - > >> To start a new topic, e-mail: users@tomcat.apache.org > >> To unsubscribe, e-mail: [EMAIL PROTECTED] > >> For additional commands, e-mail: [EMAIL PROTECTED] > >> > >> > >> > > > > > > > > > - > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Kimberly Begley
Re: jsp calling a servlet (or at least that's the goal)
it's in CATALINA_HOME/webapps/test On Wed, Mar 12, 2008 at 10:14 PM, Mark Thomas <[EMAIL PROTECTED]> wrote: > Kimberly Begley wrote: > > and my jsp form calls it like this: > > > method=post> > > What is the context path your app is deployed to? > > Mark > > > - > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Kimberly Begley
jsp calling a servlet (or at least that's the goal)
Hi, I am stuck. I am running tomcat 5 and am trying to call a servlet from a jsp. My servlet class resides in WEB-INF/classes/packagename. My web.xml looks like this UploadUnzipTest packagename.UploadUnzipTest UploadUnzipTest /servlet/UploadUnzipTest and my jsp form calls it like this: but when I click on the submit button to upload a zip file it says this: HTTP Status 404 - /servlet/UploadUnzipTest -- *type* Status report *message* */servlet/UploadUnzipTest* *description* *The requested resource (/servlet/UploadUnzipTest) is not available.* -- Apache Tomcat/5.5.26I have reloaded the app with the manager, stopped tomcat, started tomcat - shut down the whole machine and started everything up again but still nothing... Any suggestions would be greatly appreciated Thanks --
Re: file upload servlet
ah - ok - thanks for clearing that up. On Thu, Feb 28, 2008 at 4:59 PM, Bob Hall <[EMAIL PROTECTED]> wrote: > > --- 10:07PM Wed 27 Feb 2008 Kimberly Begley > <[EMAIL PROTECTED]> wrote: > > > Hi - I'm trying to compile come java code to upload > > a file but am getting > > errors - it looks like it can't find the > > javax.servlet stuff to import and > > from what I've read online everyone talks about > > having the directory in the > > classpath but I have also read not to mess with my > > classpath - I'm trying to > > compile it from my > > catalina_home/webapps/appname/WEB_INF directory - > > does > > anyone have any suggestions? I'm sure it's obvious > > but I just can't see it. > > > > The CLASSPATH warnings are associated with starting > Tomcat - not compiling your java code; servlet-api.jar > needs to be in your CLASSPATH. > > You should also take a look at the commons fileUpload > project; http://commons.apache.org/fileupload/ > > HTH - Bob > > > > > > > Be a better friend, newshound, and > know-it-all with Yahoo! Mobile. Try it now. > http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ > > > --------- > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Kimberly Begley
file upload servlet
Hi - I'm trying to compile come java code to upload a file but am getting errors - it looks like it can't find the javax.servlet stuff to import and from what I've read online everyone talks about having the directory in the classpath but I have also read not to mess with my classpath - I'm trying to compile it from my catalina_home/webapps/appname/WEB_INF directory - does anyone have any suggestions? I'm sure it's obvious but I just can't see it. This is my java file: FileUploadBean.java package foo; import java.io.*; import java.net.*; import javax.servlet.*; import javax.servlet.http.*; public class FileUploadBean extends HttpServlet { public void doUpload(HttpServletRequest request) throws IOException { PrintWriter pw = new PrintWriter( new BufferedWriter(new FileWriter("Demo.out"))); ServletInputStream in = request.getInputStream(); int i = in.read(); while (i != -1) { pw.print((char) i); i = in.read(); } pw.close(); } } and my jsp page looks like this: <%@ page import="java.util.*" %> <%@ page import="java.lang.*" %> <%-- ResourceBundle bundle =null; public void jspInit() { bundle = ResourceBundle.getBundle("forms"); } --%> <% TheBean.doUpload(request); %> When run "javac -d . FileUploadBean.java" I get this error: javac -d . FileUploadBean.java -- 1. ERROR in FileUploadBean.java (at line 3) import javax.servlet.*; ^ The import javax.servlet cannot be resolved -- 2. ERROR in FileUploadBean.java (at line 4) import javax.servlet.http.*; ^ The import javax.servlet cannot be resolved -- 3. ERROR in FileUploadBean.java (at line 8) public void doUpload(HttpServletRequest request) throws ^^ HttpServletRequest cannot be resolved to a type -- 4. ERROR in FileUploadBean.java (at line 12) ServletInputStream in = request.getInputStream(); ^^ ServletInputStream cannot be resolved to a type -- 4 problems (4 errors) --
Re: not reading my /etc/tomcat5/tomcat5.conf file
Thanks - I did as you suggested and have a new Tomcat5 and JVM running - without any problems so far! Thanks so much, Kimberly On Thu, Feb 21, 2008 at 10:57 AM, Philip Cote <[EMAIL PROTECTED]> wrote: > I concur that that's the easiest way to do this. However, if you MUST > work with 3rd party repackaged tomcat (or 3rd party repackaged distro > versions of anything for that matter), the Cent OS forums would probably > be the best place to ask. > > On Tue, 2008-02-19 at 21:46 -0600, Caldarale, Charles R wrote: > > > From: Kimberly Begley [mailto:[EMAIL PROTECTED] > > > Subject: not reading my /etc/tomcat5/tomcat5.conf file > > > > > > I'm running CentOS 5 with Tomcat5 (5.5.2.0) that came with > > > the install. > > > > I'd strongly recommend you throw that away and download and install a > > real Tomcat from http://tomcat.apache.org. The 3rd-party repackaged > > versions give no end of headaches. > > > > You may also need to install a real JVM; some of the Linux distributions > > come with GNU Java, and that is not suitable for any real work. > > > > - Chuck > > > > > > THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY > > MATERIAL and is thus for use only by the intended recipient. If you > > received this in error, please contact the sender and delete the e-mail > > and its attachments from all computers. > > > > - > > To start a new topic, e-mail: users@tomcat.apache.org > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > ----- > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Kimberly Begley
not reading my /etc/tomcat5/tomcat5.conf file
Hi, I'm running CentOS 5 with Tomcat5 (5.5.2.0) that came with the install. If I try to run dtomcat5 stop or version etc I get the following message below - I have also pasted the tomcat5.conf file below- it is obvious that dtomcat5 is not reading the /etc/tomcat5/tomcat5.conf file - what do I have wrong? Am I going about starting/stopping/getting versions for tomcat the wrong way? Any suggestions? Thanks [EMAIL PROTECTED] conf]# dtomcat5 stop Found JAVA_HOME: /usr/lib/java Please complete your /etc/tomcat5/tomcat5.conf so we won't have to look for it next time Using CATALINA_BASE: /usr Using CATALINA_HOME: /usr Using CATALINA_TMPDIR: /usr/temp Using JRE_HOME: /usr/bin/dtomcat5: line 347: /usr/lib/java/bin/java: No such file or directory [EMAIL PROTECTED] conf]# dtomcat5 version Found JAVA_HOME: /usr/lib/java Please complete your /etc/tomcat5/tomcat5.conf so we won't have to look for it next time Using CATALINA_BASE: /usr Using CATALINA_HOME: /usr Using CATALINA_TMPDIR: /usr/temp Using JRE_HOME: /usr/bin/dtomcat5: line 366: /usr/lib/java/bin/java: No such file or directory [EMAIL PROTECTED] conf]# I have updated the /etc/tomcat5/tomcat5.conf file to read as follows: # tomcat5 service configuration file # you could also override JAVA_HOME here # Where your java installation lives JAVA_HOME="/usr/bin/java" # Where your tomcat installation lives # That change from previous RPM where TOMCAT_HOME # used to be /var/tomcat. # Now /var/tomcat will be the base for webapps only CATALINA_HOME="/usr/share/tomcat5" JASPER_HOME="/usr/share/tomcat5" CATALINA_TMPDIR="/usr/share/tomcat5/temp" JAVA_ENDORSED_DIRS="/usr/share/tomcat5/common/endorsed" # You can pass some parameters to java # here if you wish to #JAVA_OPTS="-Xminf0.1 -Xmaxf0.3" # Use JAVA_OPTS to set java.library.path for libtcnative.so #JAVA_OPTS="-Djava.library.path=/usr/lib # Bug 190: # https://www.jpackage.org/bugzilla/show_bug.cgi?id=190 # System property catalina.ext.dirs should be set to its default value # for ExtensionValidator to be functional. JAVA_OPTS="$JAVA_OPTS - Dcatalina.ext.dirs=$CATALINA_HOME/shared/lib:$CATALINA_HO ME/common/lib" # What user should run tomcat TOMCAT_USER="tomcat" # You can change your tomcat locale here #LANG=en_US # Time to wait in seconds, before killing process SHUTDOWN_WAIT=30 # Set the TOMCAT_PID location CATALINA_PID=/var/run/tomcat5.pid # Connector port is 8080 for this tomcat5 instance #CONNECTOR_PORT=8080 # If you wish to further customize your tomcat environment, # put your own definitions here --