Tomcat9, JSP, CSS and JS not loading in Firefox
Hello, My question is about loading a JSP page in Firefox (or Google Chrome) and not having the CSS loaded and the JS operational. I am using Tomcat v9.0 and Eclipse Java EE IDE v.2019-12 (4.14.0). When I'm developing using Eclipse IDE, I usually: - select a JSP in the "WebContent" directory in the Eclipse workspace, - right-click, - select "Debug/Run As -> Debug/Run on Server" and the Webapp starts debugging/running. With the URL "http ://localhost//.jsp", the page gets displayed correctly in the Web browser that Eclipse "embeds" (maybe I.E., I don't know). In Internet Explorer, the page is displayed correctly too. Now, if I copy this same URL "http ://localhost//.jsp" in Firefox or Google Chrome, it's like the CSS is not applied to the page, and the Javascript code doesn't run when it should. Note that I didn't use to have that problem before I upgraded Eclipse and Tomcat (I used Tomcat v.8 before). Below is the beginning of the JSP page: -- <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib prefix="c" uri="http ://java.sun.com/jsp/jstl/core"%> ${initParam['S_IF_MSG_TITLE_WELCOME']} -- Also in Firefox, I pressed Ctrl + Shift + k and saw the error message: -- The stylesheet http ://localhost/fr/css/fo.css was not loaded because its MIME type, “text/html”, is not “text/css”. -- and the warning: -- The script from “http ://localhost/fr/js/fo.js” was loaded even though its MIME type (“text/html”) is not a valid JavaScript MIME type. -- Can you help me solve that problem? Best regards. -- Léa P.S. I added a space after each occurrence of the pattern "http" in this message. -- Sent from: http://tomcat.10.x6.nabble.com/Tomcat-User-f1968778.html - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: ClassNotFoundException - Involving a class implementing Filter and two projects depending on another one
On 3/30/2015 2:36 AM, Tim Watts-3 [via Tomcat] wrote: On Sun, 2015-03-29 at 12:56 -0400, Tim Watts wrote: On Sun, 2015-03-29 at 18:06 +0200, Lmhelp1 wrote: On 3/29/2015 5:36 PM, André Warnier [via Tomcat] wrote: Lmhelp1 wrote: Hello, Thank you for reading my post. I am getting a ClassNotFoundException. Below is the situation. - I'm working with Eclipse (Luna), Tomcat 8 and Java 8. - I have three projects project1, project2 and project3. - project1 and project2 depend on the third project project3. In Project - Properties - Java Build Path - Projects, I added project3 for both projects project1 and project2. - project3 is a Java project. - project1 and project2 are Dynamic Web Projects. - project3 defines the class MyFilter which implements Filter and which I put in the package my.package. - project1 contains a web.xml file which contains the following elements: [...] filter filter-nameMyFilter/filter-name filter-classmy.package.MyFilter/filter-class init-param param-namerequestEncoding/param-name param-valueUTF-8/param-value /init-param /filter filter-mapping filter-nameMyFilter/filter-name url-pattern/*/url-pattern /filter-mapping [...] - project2 contains a web.xml file which contains the following elements (same as in project 1): [...] filter filter-nameMyFilter/filter-name filter-classmy.package.MyFilter/filter-class init-param param-namerequestEncoding/param-name param-valueUTF-8/param-value /init-param /filter filter-mapping filter-nameMyFilter/filter-name url-pattern/*/url-pattern /filter-mapping [...] When running a JSP of project1 on the Tomcat server, I get the error: SEVERE: Exception starting filter MyFilter java.lang.ClassNotFoundException: my.package.MyFilter There are no errors at build time. I just would like to mention that I'm working with Tomcat 8 for the first time. It used to work with Tomcat 7 but I might have done something more to make it work... I don't remember what... What can I do to solve that problem? Please let me know if you need additional information or if I'm not clear enough. I do not really know how to translate this for Eclipse but if this was a stand-alone Tomcat, the way you describe it above, project1 and project2 (when deployed) should also have the class available under their respective (catalina_base)/webapps/projectX/WEB-INF/classes/ directory (or /WEB-INF/classes/lib/, if in a jar). Is it the case ? Thank you for your answer. No, it is not the case. - There are no .class files from project3 under classes directories for the two projects project1 and project2. - I didn't make a .jar file out of project3 because I don't want to have to do it every time I change the code of the classes in project3... Note - If I do not add project3 via Project - Properties - Java Build Path - Projects for both projects project1 and project2 I get hundreds of errors. So clearly this is a required setting... I don't know what is missing... Thank you for helping me. Best regards. -- Léa In Eclipse, try Project / Properties / Deployment Assembly. Add project 'project3'. It should add project3's resulting jar file to WEB-INF/lib or resulting classes to WEB-INF/classes depending on how project3 is configured. UPDATE: The 2nd part of that sentence is not true; it will always add the resulting jar file of project3. However, it will create jar file on the fly when the webapp is re/deployed OR when project3 is modified. Keep in mind that this is simply a quick dirty way of testing the app from within Eclipse and NOT suitable for building a deployable war file. You should use Maven or Ant or etc. for that. Ok. Thank you. -- Léa -- View this message in context: http://tomcat.10.x6.nabble.com/ClassNotFoundException-Involving-a-class-implementing-Filter-and-two-projects-depending-on-another-oe-tp5032615p5032638.html Sent from the Tomcat - User mailing list archive at Nabble.com.
Re: Debugging a Webapp in Eclipse running Tomcat as a stand-alone JVM process
Thank you for yours answers. @Glen Peterson: Thanks for sharing about the method you use. Best regards. -- View this message in context: http://tomcat.10.x6.nabble.com/Debugging-a-Webapp-in-Eclipse-running-Tomcat-as-a-stand-alone-JVM-process-tp5025598p5025883.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Debugging a Webapp in Eclipse running Tomcat as a stand-alone JVM process
Thank you for your answer. Konstantin Kolinko wrote: Deployment can be done from Ant or from Maven. There exists tools for that. Ok, I understand. Konstantin Kolinko wrote: If you are developing your web application, is there a reason why you run Tomcat standalone and not from within Eclipse IDE? Here is why. On a Unix machine, I start Tomcat as a service, as a non-root user and via JSVC. (This is the as a non-root user part which is important here for me). Below is what I tried. First test: - remove /etc/init.d/tomcat7 from /etc/init.d/ and reboot the machine so that Tomcat is not automatically started at all (and so that I'm sure no other process is using the TCP ports 80 and 443) ; - run Eclipse as a non-root user ; - add a local Tomcat server to the Eclipse workspace ; - run a JSP on the server. = I get the error message: Several ports (443, 80) required by Tomcat v7.0 Server at localhost are already in use. The server may already be running in another process, or a system process may be using the port. To start this server you will need to stop the other process or change the port number(s). Second test: - run Eclipse as root ; - run a JSP on the server. = There is no error message anymore. BUT, I need to run Tomcat as a non-root user. In particular, I need it for subsequent operations made via the webapps deployed on the Tomcat server (for example: directories and files creations). This is the reason why I wanted to use the standalone Tomcat that is started via the /etc/init.d/tomcat7 script. Usually, on my Windows development machine, I do not have these kind of issues. This is why I normally and usually use the Tomcat running on the Eclipse JVM. Does it make any sense? I wonder how people developing daily on a Unix machine do to debug their webapps in Eclipse as a non-root user. Maybe you do? I would totally be glad to know what is the usual practice. Best regards. -- View this message in context: http://tomcat.10.x6.nabble.com/Debugging-a-Webapp-in-Eclipse-running-Tomcat-as-a-stand-alone-JVM-process-tp5025598p5025651.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Debugging a Webapp in Eclipse running Tomcat as a stand-alone JVM process
Thank you for your answer. Konstantin Kolinko wrote: Why do you need the ports to be 80 and 443? (You cannot open those on Linux unless you are a root). You can a) change the port numbers in your configuration b) use firewall (iptables) to map different local ports to those external ones https://wiki.apache.org/tomcat/HowTo#How_to_run_Tomcat_without_root_privileges.3F Well, apparently, according to the author of this article, I chose the best method (JSVC)! But thank you very much for pointing me towards this article and this FAQ which looks very interesting, full of interesting questions (and answers). Indeed the iptables solution looks attracting. I chose JSVC because I wanted Tomcat to be started at boot time and, if I'm not mistaken, this is root who runs the /etc/init.d/ scripts including the /etc/init.d/tomcat7 script... but I needed Tomcat to be run as a non-root user etc. etc. Konstantin Kolinko wrote: Also, https://wiki.apache.org/tomcat/FAQ/Linux_Unix#Q5 That's exactly what I did and I did it for exactly the same reasons given in this article. I didn't install the Tomcat Debian package. I'm glad I did right. Best regards. -- View this message in context: http://tomcat.10.x6.nabble.com/Debugging-a-Webapp-in-Eclipse-running-Tomcat-as-a-stand-alone-JVM-process-tp5025598p5025663.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Debugging a Webapp in Eclipse running Tomcat as a stand-alone JVM process
Thank you for your answers. @MarkEggers Thank you very much for sharing. Christopher Schultz wrote There are reasons to use jsvc, but the ability to run as a non-root uses is not one of them. What are these reasons according to you (apart from running Tomcat as a daemon on Unix which was also one of my goals at the time)? Also Excerpt from here: http://tomcat.apache.org/tomcat-7.0-doc/setup.html#Unix_daemon jsvc has other useful parameters, such as -user which causes it to switch to another user after the daemon initialization is complete. This allows, for example, running Tomcat as a non privileged user while still being able to use privileged ports. Thanks. Best regards. -- View this message in context: http://tomcat.10.x6.nabble.com/Debugging-a-Webapp-in-Eclipse-running-Tomcat-as-a-stand-alone-JVM-process-tp5025598p5025674.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Debugging a Webapp in Eclipse running Tomcat as a stand-alone JVM process
Hello and thank you for reading my post. My problem is about debugging a Webapp in Eclipse running Tomcat as a stand-alone JVM process. -- In more details -- Below is what I would like to do: - Start Tomcat: - on Windows: via startup.bat in a cmd.exe ; - on Unix (Debian Squeeze): via JSVC in a /etc/init.d/tomcat7 script. - Run Eclipse (Juno): as a non-root user (say U). - Debug a Webapp in Eclipse running Tomcat as a stand-alone JVM process (NOT running Tomcat from within the Eclipse JVM). This article states that it is possible to do this: http://blogs.mulesoft.org/debugging-your-tomcat-webapp-with-eclipse/ Excerpt: Once you have Tomcat running successfully as a separate process, and your webapp happily running on it, you can begin configuring remote debugging. A) First of all, I do not manage to: have Tomcat run successfully as a separate process, and your webapp happily running on it [in Eclipse (personal addition)]. Can you tell me what I have to do? (I hope it doesn't mean putting a .war file in the Tomcat webapps directory because I know how to do that already). B) Second of all. As for the debugging part, below is what I did so far: 1) In startup.bat, I added the two lines: set JPDA_ADDRESS=8000 set JPDA_TRANSPORT=dt_socket I modified the line: call %EXECUTABLE% jpda start %CMD_LINE_ARGS% Below is the startup.bat that I have presently: -- @echo off rem --- rem Start script for the CATALINA Server rem --- setlocal rem Guess CATALINA_HOME if not defined set CURRENT_DIR=%cd% if not %CATALINA_HOME% == goto gotHome set CATALINA_HOME=%CURRENT_DIR% if exist %CATALINA_HOME%\bin\catalina.bat goto okHome cd .. set CATALINA_HOME=%cd% cd %CURRENT_DIR% :gotHome if exist %CATALINA_HOME%\bin\catalina.bat goto okHome echo The CATALINA_HOME environment variable is not defined correctly echo This environment variable is needed to run this program goto end :okHome set JPDA_ADDRESS=8000 set JPDA_TRANSPORT=dt_socket set EXECUTABLE=%CATALINA_HOME%\bin\catalina.bat rem Check that target executable exists if exist %EXECUTABLE% goto okExec echo Cannot find %EXECUTABLE% echo This file is needed to run this program goto end :okExec rem Get remaining unshifted command line arguments and save them in the set CMD_LINE_ARGS= :setArgs if %1== goto doneSetArgs set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1 shift goto setArgs :doneSetArgs call %EXECUTABLE% jpda start %CMD_LINE_ARGS% :end -- 2) In Eclipse, I went to the menu Run - Debug Configurations... - Remote Java Application I entered the following values: -- Name: ExternalTomcat Project: webapp_pjt1 Connection type: Standard (Socket Attach) Host: localhost Port: 8000 -- I clicked the buttons Apply and then Debug. 3) I set a breakpoint somewhere relevant in the Webapp code. 4) I tried to send an HTTP request to the Tomcat server: I entered https://localhost/webapp_pjt1/welcome.jsp in a browser (NOT the Eclipse internal browser). I got a HTTP 404 error. Can you see what I'm doing wrong? Best regards. -- View this message in context: http://tomcat.10.x6.nabble.com/Debugging-a-Webapp-in-Eclipse-running-Tomcat-as-a-stand-alone-JVM-process-tp5025598.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Debugging a Webapp in Eclipse running Tomcat as a stand-alone JVM process
Thank you for your answer. Your link helped. What was missing from the scenario I described previously was: exporting the .war of the webapps into the Tomcat webapps directory. Actually, I was hoping it would be done automatically somehow... :'/ Is there - by any chance - an option somewhere that I have been missing which would automatically export the webapps .war archives to the Tomcat webapps directory... at build time for instance? Hope my question is clear enough. Best regards. -- View this message in context: http://tomcat.10.x6.nabble.com/Debugging-a-Webapp-in-Eclipse-running-Tomcat-as-a-stand-alone-JVM-process-tp5025598p5025614.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: From HTTP to HTTPS request.getHeader(referer)
Hello and thank you for your answers. I would like to say that my problem is solved (even though I would like to answer the remarks you made). I can't really tell what combination of adjustments (see my previous posts) are responsible for it. I just did things with more care than when I do things hastily (or just to try something). I'm saying this because (see below) I thought sendRedirect() was working only if I passed it the complete HTTPS URL of the JSP I was willing to redirect to user towards. I appears that now, it works if I only pass the JSP page name to sendRedirect() (like I did in the past when dealing with HTTP requests only). So, I don't really know what to think :'/ Christopher Schultz wrote: If you are already in HTTPS protocol and don't want to switch, then you shouldn't have to specify the protocol in the redirect. Well, indeed, it looks like I don't have to specify the protocol anymore... (see my comment above). Christopher Schultz wrote: Yes, they don't really help in any way because they don't describe use cases. You didn't provide anything like I want X, I tried Y, and Z happened so it's hard to help you out. Well, it troubles me because, I was willing to give you some relevant information (I just often do not know which and I also understand it's not easy for you to understand my stuff when you only get pieces of it). I wanted to know if my HTTPS configuration for a standalone Tomcat serving all the pages of some webapps with the HTTPS protocol is fine or not. The configuration details I sent previously are really the only thing I do (to have Tomcat serve the webapps JSPs with the HTTPS protocol)... Normally, if I'm not mistaken, I can switch back to HTTP by: 1) Removing the security-constraint element from the webapp web.xml file. 2) Replacing the three connectors: Connector port=quot;443quot; [...] lt;Connector port=quot;80quot; [...] lt;Connector port=quot;8009quot; [...] from the Tomcat quot;server.xmlquot; file (see the post in which I posted the config) and replace them with the two connectors: lt;Connector port=quot;80quot; protocol=quot;HTTP/1.1quot; connectionTimeout=quot;2quot; redirectPort=quot;8443quot; / Connector port=8009 protocol=AJP/1.3 redirectPort=8443 / To try to give you an answer: this is probably a typical use case in the webapp: - The user has requested a JSP page x.jsp: it can see this page properly in its browser. - The user submits this JSP's form (which has an action attribute mapped with a servlet in web.xml). - The doPost() method of the servlet is invoked. - Some instructions are executed (database access for example). - Before exiting (return;) the doPost(), I execute response.sendRedirect(y.jsp). This used to fail before: I don't remember the error but the page y.jsp wasn't served at all. This is working now. I thought that the two things I configure (1. security-constraint element the web.xml of the webapp and 2. the connectors Tomcat server.xml) are just enough to show what I do to make Tomcat serve the the JSPs of some webapps with the HTTPS protocol... If this config looks good and if what I wrote just now doesn't bring anything new to the table, please ignore it since its working now. Christopher Schultz wrote: Look at your access log to file out what's going on when you request an http:// URL. Below is what I can find in the Tomcat access logs file: Requested resource: http://host/webapp/welcome.jsp 192.168.2.19 - - [06/Nov/2014:11:06:03 +0100] GET /webapp/welcome.jsp HTTP/1.1 302 - 192.168.2.19 - - [06/Nov/2014:11:06:19 +0100] GET /webapp/welcome.jsp HTTP/1.1 200 5361 Requested resource: https://host/webapp/welcome.jsp 192.168.2.19 - - [06/Nov/2014:11:08:06 +0100] GET /webapp/welcome.jsp HTTP/1.1 200 5361 Should the HTTPS protocol be mentioned somewhere in this file? Just reading this, can someone (you for instance) infer that the page welcome.jsp was served using the HTTPS protocol? Is there another log file where this can be checked? Thank you for mentioning the 302 response: not that it particularly enlightens me but maybe one day it will be clearer for me. Best regards. -- View this message in context: http://tomcat.10.x6.nabble.com/From-HTTP-to-HTTPS-request-getHeader-referer-tp5024782p5025082.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail:
Re: From HTTP to HTTPS request.getHeader(referer)
Hi, Christopher Schultz wrote: If you want to switch protocols I don't think I want that... but maybe I do not understand properly what you mean... For the webapp I've been considering in that thread, I would like Tomcat to serve pages only via HTTPS. I do not want some pages to be served via HTTP and some others to be served via HTTPS. I don't know if it clarifies my point... Have you had a little time to have a look at the configuration files I posted yesterday (complete server.xml and excerpt from the webapp's web.xml)? 1) In web.xml, I set the CONFIDENTIAL security constraint which, as far as I understood, imposes the use of the HTTPS protocol to serve the JSP pages of the webapp. 2) Ideally, I would like the webapp users to enter HTTPS URLs in their browser URL bar/directly click URLs like https://host/webapp/a-page.jsp. But I also would like them to be able to enter HTTP URLs like http://host/webapp/a-page.jsp which are, to my understanding automatically transformed into https://host/webapp/a-page.jsp thanks to the server.xml configuration line: Connector port=80 enableLookups=false redirectPort=443/ I realize I do not know what happens to the request in that case (http://host/webapp/a-page.jsp). Is it encoded or not? Terence M. Bandoian wrote: I'm not sure how you're using it but it's worth pointing out that response.sendRedirect Sends a temporary redirect response to the client... The client (browser) must then send another request to the server before any additional processing takes place. In contrast, pageContext.forward takes place entirely on the server. I didn't know that. I thought there was one HTTP(S) request and one HTTP(S) response only. How can the mechanism you describe above affect the use of HTTPS for a webapp with the CONFIDENTIAL security constraint on a standalone Tomcat server? I'm using sendRedirect() in a very straightforward way I think. I use some sort of pipelines for a subset S of JSPs in the webapp: 1) Given a JSP s in S, it contains a form with an action attribute mapped via web.xml to a servlet L. 2) The servlet L implements either a doPost() or (rarely) a doGet() method. 3) Given what was submitted via the form, work is performed in the servlet. 4) When the servlet work is done and depending on the result (success 1, ..., success n / error 1, ..., error n), the servlet redirects towards the next JSP using the method sendRedirect(). Is there a temporary redirect response to the client in that case? Is this behavior documented somewhere? I could totally benefit from a good documentation... Best regards. -- View this message in context: http://tomcat.10.x6.nabble.com/From-HTTP-to-HTTPS-request-getHeader-referer-tp5024782p5024951.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: From HTTP to HTTPS request.getHeader(referer)
Hi, thank you for your answer. On 2014-11-03 4:34 PM, Christopher Schultz wrote: Redirects definitely work with HTTPS. You must be doing something wrong. Perhaps a configuration mistake with a port number or something like that. My configuration in Tomcat 7.0.55 server.xml is: ( - basically it is the same as the one packaged in the Tomcat distribution, I only changed the connectors ; - I removed all the comments and I'm testing on localhost for this config. ) - ?xml version='1.0' encoding='utf-8'? Server port=8005 shutdown=SHUTDOWN Listener className=org.apache.catalina.core.AprLifecycleListener SSLEngine=on / Listener className=org.apache.catalina.core.JasperListener / Listener className=org.apache.catalina.core.JreMemoryLeakPreventionListener / Listener className=org.apache.catalina.mbeans.GlobalResourcesLifecycleListener / Listener className=org.apache.catalina.core.ThreadLocalLeakPreventionListener / GlobalNamingResources Resource name=UserDatabase auth=Container type=org.apache.catalina.UserDatabase description=User database that can be updated and saved factory=org.apache.catalina.users.MemoryUserDatabaseFactory pathname=conf/tomcat-users.xml / /GlobalNamingResources Service name=Catalina Connector port=443 keystoreFile=where/the/ssl/keystore/is/kstore.txt keystorePass=example SSLEnabled=true acceptCount=100 clientAuth=false disableUploadTimeout=true enableLookups=false maxThreads=25 protocol=org.apache.coyote.http11.Http11NioProtocol scheme=https secure=true sslProtocol=TLS / Connector port=80 enableLookups=false redirectPort=443/ Connector port=8009 protocol=AJP/1.3 redirectPort=443 / Engine name=Catalina defaultHost=localhost Realm className=org.apache.catalina.realm.LockOutRealm Realm className=org.apache.catalina.realm.UserDatabaseRealm resourceName=UserDatabase/ /Realm Host name=localhost appBase=webapps unpackWARs=true autoDeploy=true Valve className=org.apache.catalina.valves.AccessLogValve directory=logs prefix=localhost_access_log. suffix=.txt pattern=%h %l %u %t quot;%rquot; %s %b / /Host /Engine /Service /Server - As for the webapp I would like to HTTPS serve, I only added what follows to its web.xml: - security-constraint web-resource-collection web-resource-namesecuredapp/web-resource-name url-pattern/*/url-pattern /web-resource-collection user-data-constraint transport-guaranteeCONFIDENTIAL/transport-guarantee /user-data-constraint /security-constraint - Is there something wrong or missing? On 2014-11-03 4:34 PM, Christopher Schultz wrote: So use redirects. They should work and you should figure out why they aren't working. Put your code back the way you had it, take more data, and post a new question if you need help. Ok. Thank you. I restored the sendRedirect() calls I was making at first. I proceeded like I described in my last post: passing complete URLs to the sendRedirect() methods (ex. sendRedirect(https://host/webapp/example.jsp;);). As a reminder, before, I used to pass only the JSP page name as an argument to the sendRedirect() method (ex. sendRedirect(example.jsp);). It looks like that the webapp is now working nicely. I noticed your comment about encodeRedirectURL(). Thanks for mentioning it. When you use a forward, you will always end up with the URL the client first used as what the client sees. If you want to accept data (e.g. POST) *and* prepare some data for the next screen to be seen, consider a POST-then-redirect scheme: 1. Client POSTs to some URL e.g. /do_example 2. /do_example servlet runs and handles the POST data, then redirect()s to /prepare_view 3. /prepare_view servlet runs and gathers whatever data is appropriate for the next display screen and forward()s to /example1.jsp After all that, the user is looking at the URL /prepare_view instead of /do_example. That way, your referrer for the next POST will be /prepare_view instead of /do_example. Thank you. It's interesting. What if the user hits the BACK button and looks at a previous page, then re-submits that old page? Your server thinks that the source page was example1.jsp but the client actually posted example0.jsp or something else... Web application workflow management is non-trivial. Yes, it's tricky. Best
Re: From HTTP to HTTPS request.getHeader(referer)
Hello Mark, Chris and Terence. Thank you for your answers. After reading them and observing a few things I realized that my problem is not exactly the one I described at first. Christopher Schultz-2 wrote The Referer is going to be the URL that was showing in the web browser when the user clicked on the Submit button. This is right. I hadn't noticed it but the URL which is showing is NOT https://host/webapp/example1.jsp. Instead, it is https://host/webapp/do_example. So, what I was describing as abnormal in my first post is actually normal. So the problem is coming from elsewhere... Before I tried to make the webapp work with HTTPS, I was always using calls like these: -- response.sendRedirect(example1.jsp); -- Last week, I replaced all these calls with these new ones: -- requestDispatcher = getServletContext().getRequestDispatcher(/example1.jsp); requestDispatcher.forward(request, response); -- (with the appropriate JSP of course). I made that change because sendRedirect() didn't work with HTTPS. I didn't mention this before because I thought it was solving this other problem. Instead, it provokes new ones. What I actually would like is the webapp to behave like before: showing JSP page names in the URLs bar instead of URL patterns: in a given servlet, I generally have several forward() calls and hence several different .jsp pages to forward to depending on what happens inside the servlet. Having all of them replaced by something like do_example is kind of not what I had planned. It's definitely very problematic. So, hum, as I didn't asked it at the time: why can't I go on using sendRedirect() along with HTTPS? If I have to use forward(), is there any way I could make it behave the way I described above? Is there another method I could use that would suit my needs? Best regards. P.S. For the problem I was posting at first, as I don't really need to rely on the referer request header, I can instead, set a session attribute in each JSP. In example1.jsp for instance: c:set var=sessAtt value=example1.jsp scope=session/c:set When in the doPost() method of the servlet, I'll know which JSP form what submitted... -- View this message in context: http://tomcat.10.x6.nabble.com/From-HTTP-to-HTTPS-request-getHeader-referer-tp5024782p5024848.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: From HTTP to HTTPS request.getHeader(referer)
Léa Massiot wrote Before I tried to make the webapp work with HTTPS, I was always using calls like these: -- response.sendRedirect(example1.jsp); -- Last week, I replaced all these calls with these new ones: -- requestDispatcher = getServletContext().getRequestDispatcher(/example1.jsp); requestDispatcher.forward(request, response); -- (with the appropriate JSP of course). I made that change because sendRedirect() didn't work with HTTPS. I didn't mention this before because I thought it was solving this other problem. Just a precision: if I use sendRedirect(), the error I get is: -- Nov 02, 2014 4:27:25 PM org.apache.coyote.http11.AbstractHttp11Processor process INFO: Error parsing HTTP request header Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level. -- -- View this message in context: http://tomcat.10.x6.nabble.com/From-HTTP-to-HTTPS-request-getHeader-referer-tp5024782p5024849.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: From HTTP to HTTPS request.getHeader(referer)
Hi again. It looks like sendRedirect() is working if I pass it a HTTPS URL as an argument: - String s_prov = request.getScheme() + :// + request.getServerName() + request.getContextPath() + / + example1.jsp; response.sendRedirect(s_prov); - Nota: in my case, request.getScheme() is equal to https. I think I'm going back to sendRedirect()... Snif :'/, it's a lot of matches to replace back (from forward() to sendRedirect())... Best regards. -- View this message in context: http://tomcat.10.x6.nabble.com/From-HTTP-to-HTTPS-request-getHeader-referer-tp5024782p5024851.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
From HTTP to HTTPS request.getHeader(referer)
Hello and thank you for reading my post. I'm trying to make a webapp work with HTTPS. It was working properly with HTTP. Below is the problem I have. Inside a servlet, in its doPost() method, to check whether the incoming JSP is example1.jsp or example2.jsp, I am using the following piece of code: --- s_referer = request.getHeader(referer); if(s_referer.contains(example1.jsp) == true) { b_jspReferer1 = true; } if(s_referer.contains(example2.jsp) == true) { b_jspReferer2 = true; } --- In example1.jsp and example2.jsp there is a form element which action attribute is set to do_example: --- form method=post action=do_example [...] /form --- Now that I'm using HTTPS, s_referer is always equal to do_example in the servlet. Before, it used to be either example1.jsp in case the incoming JSP was example1.jsp and example2.jsp in case the incoming JSP was example2.jsp. I don't know how to correct my code to be able to discriminate between the two JSPs. Can you please help me? I apologize in advance for the barbaric expression incoming JSP. I hope my point is understandable despite unfortunate expression. Best regards. -- View this message in context: http://tomcat.10.x6.nabble.com/From-HTTP-to-HTTPS-request-getHeader-referer-tp5024782.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: HTTPS / URLs with no port number / Tomcat only
Christopher Schultz-2 wrote A bit of warning: when modifying iptables, you need to be very careful that you don't wipe-out any rules that allow you to gain remote access to the server. For instance, if you have a default rule to DROP all packets and an exception that allows port 22 (ssh) traffic, then flushing all the rules in a table can make it impossible for you to revert the change without remote-rebooting (or, worse yet, paying someone to walk into the cage and push the reset button). Yes right, fortunately I wasn't working on a remote machine. On Debian Wheezy, the following set of commands actually disables the firewall: --- iptables -F iptables -X iptables -t nat -F iptables -t nat -X iptables -t mangle -F iptables -t mangle -X iptables -P INPUT ACCEPT iptables -P OUTPUT ACCEPT iptables -P FORWARD ACCEPT --- Best regards. -- View this message in context: http://tomcat.10.x6.nabble.com/HTTPS-URLs-with-no-port-number-Tomcat-only-tp5024482p5024571.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: HTTPS / URLs with no port number / Tomcat only
Hello and thank you for your answer. I followed your first advice. I edited server.xml ending up with the following connectors: --- Connector SSLEnabled=true acceptCount=100 clientAuth=false disableUploadTimeout=true enableLookups=false maxThreads=25 port=443 keystoreFile=D:\where\the\key\store\file\is\keystore_file.txt keystorePass=a_password protocol=org.apache.coyote.http11.Http11NioProtocol scheme=https secure=true sslProtocol=TLS proxyPort=80 / Connector port=80 enableLookups=false redirectPort=443/ Connector port=8009 protocol=AJP/1.3 redirectPort=443 / --- This configuration works on Windows meaning: http://localhost/my_webapp/a_page.jsp automatically redirects to: https://localhost/my_webapp/a_page.jsp without any port number in the URL. I tried exactly the same modification in server.xml on a Debian Wheezy machine and it doesn't work... The browser only says that The webpage is not available. I can't see anything in the log files but maybe I should... I am using jsvc to start Tomcat as a non-root user. I couldn't find any information in RUNNING.txt. I'm sorry I'm not more precise... Can you help me? Best regards. -- View this message in context: http://tomcat.10.x6.nabble.com/HTTPS-URLs-with-no-port-number-Tomcat-only-tp5024482p5024501.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: HTTPS / URLs with no port number / Tomcat only
Thank you for you answer. It was the firewall. I thought about it and I thought I was disabling it temporarily by flushing iptables (iptables -F). But apparently it's not enough... Do you know the command for disabling the firewall completely (and temporarily) without having to reboot? I just added an exception for port 443. It looks like it's working now. Cheers. -- View this message in context: http://tomcat.10.x6.nabble.com/HTTPS-URLs-with-no-port-number-Tomcat-only-tp5024482p5024506.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
HTTPS / URLs with no port number / Tomcat only
Hello and thank you for reading my post. I was willing to run only a Tomcat server and not a Tomcat server + an Apache HTTP server. Mostly because: - an article like this one: http://www.tomcatexpert.com/blog/2011/11/02/best-practices-securing-apache-tomcat-7 says, if I understand properly, that Tomcat is secure enough with what it basically implements, - and because, if possible, I don't want to have to secure an Apache HTTP server in addition to the rest of the architecture... (Actually I already made a solution work with an Apache server but I was wondering if I could do without it). So, I am willing to serve HTTPS pages only with Tomcat and with URLs not including a port number. I did some config (mostly taken from http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html and http://java.dzone.com/articles/setting-ssl-tomcat-5-minutes) I could make this work: https://localhost:8443/my_webapp/a_page.jsp And this: http://localhost/my_webapp/a_page.jsp automatically redirects to: https://localhost:8443/my_webapp/a_page.jsp Now, in all possible cases, I would like to have this URL instead: https://localhost/my_webapp/a_page.jsp (which doesn't work presently). Can this be achieved with Tomcat ONLY? And how? Best regards. -- View this message in context: http://tomcat.10.x6.nabble.com/HTTPS-URLs-with-no-port-number-Tomcat-only-tp5024482.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: How can Tomcat be started at boot time as a non-root user
Thank you George Sexton for your explanations. Best regards to you all. -- View this message in context: http://tomcat.10.x6.nabble.com/How-can-Tomcat-be-started-at-boot-time-as-a-non-root-user-tp5023810p5023899.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
How can Tomcat be started at boot time as a non-root user
Hello and thank you for reading my post. My question is about how can Tomcat be started at boot time as a non-root user. The OS is Debian Wheezy. Below is what I did already: root chown -R tomcat7.tomcat7 /opt/tomcat7/ I created a new file: /etc/init.d/tomcat7 Owner and owner group: root Permissions: 755 --- #! /bin/sh export JAVA_HOME=/opt/jdk1.7.0_67/ case $1 in start) /bin/bash /opt/tomcat7/bin/startup.sh ;; stop) /bin/bash /opt/tomcat7/bin/shutdown.sh ;; restart) /bin/bash /opt/tomcat7/bin/shutdown.sh /bin/bash /opt/tomcat7/bin/startup.sh ;; esac exit 0 --- I ran: root update-rc.d tomcat7 defaults Added to /etc/rc0.d/: K01tomcat7 Added to /etc/rc1.d/: K01tomcat7 Added to /etc/rc2.d/: S17tomcat7 Added to /etc/rc3.d/: S17tomcat7 Added to /etc/rc4.d/: S17tomcat7 Added to /etc/rc5.d/: S17tomcat7 Added to /etc/rc6.d/: K01tomcat7 At boot time, tomcat is started as root. How can it be started as tomcat7? Best regards. -- View this message in context: http://tomcat.10.x6.nabble.com/How-can-Tomcat-be-started-at-boot-time-as-a-non-root-user-tp5023810.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: How can Tomcat be started at boot time as a non-root user
Hello Dan and thank you for your answer. I installed the JSVC tool as indicated in your document http://tomcat.apache.org/tomcat-7.0-doc/setup.html#Unix_daemon I copied the jsvc executable into /opt/tomcat7/bin/. I also copied /opt/tomcat7/bin/daemon.sh into /etc/init.d and renamed it as tomcat7. I added the following lines at the beginning of /etc/init.d/tomcat7: - CATALINA_HOME=/opt/tomcat7 export CATALINA_HOME TOMCAT_USER=webadmin export TOMCAT_USER JAVA_HOME=/opt/jdk1.7.0_67 - I hope I did all this the right way... ? Now, if I reboot, log in as root and launch the command: root ps aux | grep tomcat7 I notice that there are two jsvc.exec processes, one run by root and the other one run by webadmin which UID is 1000: - root 2841 0.0 0.0 16752 412 ?Ss 16:30 0:00 jsvc.exec -java-home /opt/jdk1.7.0_67 -user webadmin -pidfile /opt/tomcat7/logs/catalina-daemon.pid -wait 10 -outfile /opt/tomcat7/logs/catalina-daemon.out -errfile 1 -classpath /opt/tomcat7/bin/bootstrap.jar:/opt/tomcat7/bin/commons-daemon.jar:/opt/tomcat7/bin/tomcat-juli.jar -Djava.util.logging.config.file=/opt/tomcat7/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs= -Dcatalina.base=/opt/tomcat7 -Dcatalina.home=/opt/tomcat7 -Djava.io.tmpdir=/opt/tomcat7/temp org.apache.catalina.startup.Bootstrap 1000 2842 8.9 1.1 2434512 97444 ? Sl 16:30 0:03 jsvc.exec -java-home /opt/jdk1.7.0_67 -user webadmin -pidfile /opt/tomcat7/logs/catalina-daemon.pid -wait 10 -outfile /opt/tomcat7/logs/catalina-daemon.out -errfile 1 -classpath /opt/tomcat7/bin/bootstrap.jar:/opt/tomcat7/bin/commons-daemon.jar:/opt/tomcat7/bin/tomcat-juli.jar -Djava.util.logging.config.file=/opt/tomcat7/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs= -Dcatalina.base=/opt/tomcat7 -Dcatalina.home=/opt/tomcat7 -Djava.io.tmpdir=/opt/tomcat7/temp org.apache.catalina.startup.Bootstrap - If I kill -9 the process owned by user 1000, another process is immediately created to replace the killed one. If I kill the process owned by root, no new process is created. And if I kill the last remaining process, the one owned by user 1000, no new process is created either. I noticed that the $CATALINA_PID file contain the PID of the process owned by user 1000. I am wondering if this is normal behavior and if it is, why is it behaving like this? Thank you for helping. Best regards. -- View this message in context: http://tomcat.10.x6.nabble.com/How-can-Tomcat-be-started-at-boot-time-as-a-non-root-user-tp5023810p5023823.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: File download using a servlet and error handling
Ok guys, thank you all: I understand better. I'll see what I can do. Best regards. -- View this message in context: http://tomcat.10.x6.nabble.com/File-download-using-a-servlet-and-error-handling-tp5023017p5023118.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
File download using a servlet and error handling
Hello and thank you for reading my post. My question is about downloading a file using a servlet and handling possible errors that may take place during the download process. 1) I have a JSP page download-file.jsp with a Download file button: == form method=post action=do_download_file [...] input type=submit name=download_file id=download_file value=Download file / [...] /form == When this button is hit by a user, the doPost() method of the servlet mapped with the action do_download_file is executed. It includes a call to the method below. 2) Everywhere on the Web one can find that type of code (for the file downloading): == public boolean downloadFile(String s_fileNameAndPath, String s_fileName, HttpServletResponse httpServletResponse) throws IOException, SQLException, ClassNotFoundException, ModelException { File file = null; long l_fileLength = -1; ServletOutputStream servletOutputStream = null; int n_bufsize = 4096; DataInputStream dataInputStream = null; int n_nbBytesRead = -1; boolean b_anErrorOccurred = false; byte[] byteBuffer; file = new File(s_fileNameAndPath); l_fileLength = file.length(); if(l_fileLength = 0) { b_anErrorOccurred = true; return b_anErrorOccurred; } n_nbBytesRead = 0; byteBuffer = new byte[n_bufsize]; servletOutputStream = httpServletResponse.getOutputStream(); httpServletResponse.setContentType(text/html); httpServletResponse.setContentLength((int) l_fileLength); httpServletResponse.setHeader(Content-Disposition, attachment; filename=\ + s_fileName + \); dataInputStream = new DataInputStream(new FileInputStream(file)); while((dataInputStream != null) ((n_nbBytesRead = dataInputStream.read(byteBuffer)) != -1)) { servletOutputStream.write(byteBuffer, 0, n_nbBytesRead); servletOutputStream.flush(); } if(true) { throw new ModelException(To provoke an error on purpose.); } dataInputStream.close(); servletOutputStream.close(); return b_anErrorOccurred; } == (Apart from the exception being thrown) this code works: it actually downloads the targeted file. You may have noticed that in the method above, I deliberately throw an exception so that I can test error handling. My problem is that, with this way of doing things, I can't tell the user that the download operation failed since the HttpServletResponse has already been consumed when the method returns... My question is: Ideally, after the download, I wish I could go back to the JSP download-file.jsp so that I can tell the user that an error occurred while downloading the file. If the download was successful, I also would like to tell the user that everything went right... I don't see how I can both download the file and redirect the user towards the download-file.jsp page with an appropriate message. Do you have an idea how I should proceed? All the best and sorry for the language approximations like consumed, etc. -- View this message in context: http://tomcat.10.x6.nabble.com/File-download-using-a-servlet-and-error-handling-tp5023017.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: File download using a servlet and error handling
Hello to you too, I was thinking maybe about an error-page... (never done that before): in case an exception is thrown after the response has been committed, maybe this error page could be sent to the user... I don't know if it's possible... nor how to do it really. Could it be a solution? Best regards. -- View this message in context: http://tomcat.10.x6.nabble.com/File-download-using-a-servlet-and-error-handling-tp5023017p5023041.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Lots of configuration descriptors
Hello and thank you for reading my post. My question is about configuration descriptors and how Tomcat deals with a lot of them. I have been thinking about a solution for a problem I have to solve. This solution would involve the creation of possibly a lot of configuration descriptors. -- About configuration descriptors (just to make sure we are talking about the same thing) -- (In my case) the configuration descriptors are XML files which contain only one XML context element. They are very simple. For example: Name --- webapp#confdescr1.xml Contents --- Context docBase=/somewhere/on/the/filesystem / Location --- webapp#confdescr1.xml is put in /etc/tomcat6/Catalina/localhost/ Then, suppose that there is a file my_file.txt in the directory /somewhere/on/the/filesystem/, Tomcat can serve it via the URL http: //localhost/webapp/confdescr1/my_file.txt. -- My questions are: -- Is Tomcat going to behave nicely (that is to say answer quick enough) if it has hundreds (even thousands) of configuration descriptors to deal with? If a user wants to download the file http: //localhost/webapp/confdescr1/my_file.txt, is it going to have to wait a long time while Tomcat is looking for the configuration descriptor webapp#confdescr1.xml to be able to serve the file my_file.txt stored in /somewhere/on/the/filesystem/? Does Tomcat implement a mechanism to find a configuration descriptor quickly, like an index? I hope my question is clear enough. Best regards. -- View this message in context: http://tomcat.10.x6.nabble.com/Lots-of-configuration-descriptors-tp5022940.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Lots of configuration descriptors
Hello Mark, Thank you for your answer and for the info about the binary search. This was the kind of info I was looking for. Yet, I guess one has to view the source code to get that kind of information... it's probably what you did... Best regards. -- View this message in context: http://tomcat.10.x6.nabble.com/Lots-of-configuration-descriptors-tp5022940p5022952.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Lots of configuration descriptors
Ok. Sorry. Very good, I didn't know... I'm just a simple Tomcat user. I didn't mind to be rude. -- View this message in context: http://tomcat.10.x6.nabble.com/Lots-of-configuration-descriptors-tp5022940p5022954.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat-user versus StackOverflow
Hello Christopher, I'm sorry I posted the same message on StackOverflow and Tomcat-Users. It's not something I usually do. When I post on two different forums, which happens sometimes, I do not write the same message nor the same title. For example: http://www.linuxquestions.org/questions/linux-general-1/force-owner-owner-group-permissions-4175497802/ In this precise case (http://tomcat.10.x6.nabble.com/Files-created-by-a-Tomcat-webapp-and-owner-owner-group-permissions-for-this-file-td5014053.html), I hadn't posted on Tomcat-Users for while. I was in hurry and thought by mistake that the forum was dead. It wasn't meant on purpose. I guess I could delete my thread on StackOverflow and thank you again for your answers both on StackOverflow and Tomcat-Users? Best regards, -- Léa Massiot -- View this message in context: http://tomcat.10.x6.nabble.com/Re-Tomcat-user-versus-StackOverflow-tp5014264.html Sent from the Tomcat - User mailing list archive at Nabble.com.
Re: Pass an object from one Webapp to another on two differents servers
According to the notations in my first post, the successive URLs are: 1) SERVER_1/WEBAPP_1/HTML_1 2) SERVER_2/WEBAPP_2/SERVLET_2 3) SERVER_1/WEBAPP_1/JSP_1 SERVLET_2 does all the work it has to do using the information provided by the user in the HTML_1's form F1. When the work is over, SERVLET_2 redirects towards JSP_1 It's a classical client - server scheme... But maybe I'm not getting properly your questions? Best regards. -- View this message in context: http://tomcat.10.n6.nabble.com/Pass-an-object-from-one-Webapp-to-another-on-two-differents-servers-tp4985870p4986202.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
RE: Pass an object from one Webapp to another on two differents servers
Hello Casper. Yes, we are ok now. I think the responses to your question are in my previous posts :) Thank you for helping me out. -- View this message in context: http://tomcat.10.n6.nabble.com/Pass-an-object-from-one-Webapp-to-another-on-two-differents-servers-tp4985870p4986207.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Pass an object from one Webapp to another on two differents servers
(Warning: there is some raw text in this post.) Hello Casper. Hello list. Thank you for your answer and your advices. Here is some interesting litterature related to my problem: Redirecting from a servlet to an exterior URL using a POST http://www.mail-archive.com/servlet-interest@java.sun.com/msg49110.html Which led me to write a programmatic POST using this code: How to use HttpURLConnection POST data to web server? http://www.xyzws.com/Javafaq/how-to-use-httpurlconnection-post-data-to-web-server/139 And, in SERVLET_2, I replaced the code (see my first post in this thread) with this one: I guess my thread's title is not really relevant anymore because this code doesn't literally pass an object from one webapp to another running on two different servers... What I'm doing here is redirecting from a servlet to an exterior URL using a POST. I'm not really displaying something user specific / session specific but Casper's comments are very interesting and may prove useful in the future for me. Thanks again :) Best regards. -- View this message in context: http://tomcat.10.n6.nabble.com/Pass-an-object-from-one-Webapp-to-another-on-two-differents-servers-tp4985870p4986091.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Pass an object from one Webapp to another on two differents servers
The user doesn't shift from WEBAPP_1 to WEBAPP_2 for good. The user will go on with WEBAPP_1 after WEBAPP_2 has done what it has to do after the form (F1) submission. Best regards. -- View this message in context: http://tomcat.10.n6.nabble.com/Pass-an-object-from-one-Webapp-to-another-on-two-differents-servers-tp4985870p4986105.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Pass an object from one Webapp to another on two differents servers
Hello Casper, Thank you for your answer. What you are explaining totally makes sense. The doPost() method of SERVLET_2 (WEBAPP_2) ends up with a sendRedirect() method call which redirects to j1.jsp, a JSP in the first webapp (WEBAPP_1). Let's forget about sessions and passing whole objects from one webapp to another. What I rather need is pass at least one parameter from the servlet SERVLET_2 to the JSP j1.jsp. I could pass these parameters using the GET method, for example here with the parameter result: And retrieve this parameter in j1.jsp like this: But I wish I could pass that parameter using the POST method... but as far as I've read, it looks like it's not possible... Best regards. -- View this message in context: http://tomcat.10.n6.nabble.com/Pass-an-object-from-one-Webapp-to-another-on-two-differents-servers-tp4985870p4986038.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Pass an object from one Webapp to another on two differents servers
I posted mistakenly in the Tomcat forum instead of here Tomcat-User (I just moved my thread). Can you help me? Best regards. -- View this message in context: http://tomcat.10.n6.nabble.com/Pass-an-object-from-one-Webapp-to-another-on-two-differents-servers-tp4985870p4985967.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat6 - Context - aliases
Hello and thank you for your answers. Christopher Schultz-2 wrote why don't you just write a simple file-fetching servlet? They are dead-simple to write This looks very interesting. André Warnier wrote you probably do /not/ want bots to be able to point directly to the documents uploaded by users Yes indeed. Thanks for pointing this out. I was just speaking in general. André Warnier wrote Presumably, it is via a POST, to a servlet you have created. That servlet knows where to store the files that are uploaded, via some parameter which it reads somewhere. Yes. André Warnier wrote Christoper's (and my own) suggestion is to create a similar servlet that serves to download the files, and which would use the same parameter to know where to download them from. Again, it looks very interesting. Maybe it's what I've been looking for from the beginning. To @André Warnier: Thank you for the two references Automatic Application Deployment and Single Sign On. If any of you two can post the code of the file-fetching servlet, it would be great. Thanks and best regards. -- View this message in context: http://tomcat.10.n6.nabble.com/Tomcat6-Context-aliases-tp4678430p4756364.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat6 - Context - aliases
@André Warnier: Thank you. -- View this message in context: http://tomcat.10.n6.nabble.com/Tomcat6-Context-aliases-tp4678430p4762217.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat6 - Context - aliases
@André Warnier: Thank you for your detailed answer. As of your objections: 1) We don't agree with each other. I *DO* care about what URLs look like: a) in general, b) for some reasons related to the user's speaking language, c) for search engines, d) ... The URL of a link can be seen in many circumstances and is used in various ways both by humans and bots. 2) I want the resources (files and other things like databases) to be stored outside the servlets container and more precisely on another partition, especially if data get erased when the context which contains them is undeployed! André Warnier wrote Do you know that when a Context is undeployed by Tomcat, all its files are deleted ? This is certainly not what I want. I would expect Tomcat to provide a mechanism for it not to happen. (See my questions at the end of this post). André Warnier wrote with your method consisting of creating a new context on-the-fly Am I? I put an_alias_1.xml in /etc/tomcat6/Catalina/localhost/ once and only once (never touch it again afterwards). André Warnier wrote But this is a logical consequence of building a context from scratch, outside of you /w context, and having Tomcat serve it, without any kind of security protecting that location. It's not exactly my full responsibility. I'm looking for a solution, remember. I'm not especially keen on that solution. André Warnier wrote An undeploy of a Context does not generally happen by itself What is the probability of such an event occurring? If it's like a rm -R on the directory, I'll forget about it. So, given your thoughtful observations, here are my questions: 1) Can you tell me how to test a context undeployment in command line (not via Tomcat Manager please)? 2) Is there any way, I can prevent a context to be undeployed ever (like setting a specific option in a configuration file, in an_alias_1.xml for example)? 3) Is there any good example illustrating how to do a cross context authentication you can point me to? Thank you for helping and best regards. -- View this message in context: http://tomcat.10.n6.nabble.com/Tomcat6-Context-aliases-tp4678430p4715558.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat6 - Context - aliases
I edited my previous post at 1:14 PM 2012/04/09. Thanks. -- View this message in context: http://tomcat.10.n6.nabble.com/Tomcat6-Context-aliases-tp4678430p4715649.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat6 - Context - aliases
Christopher Schultz-2 wrote Do you really need crossContext=true here? I guess not since - as I just tested - removing it doesn't change anything... Thank you. So I removed the crossContext attribute (and the path attribute) and the new contents of an_alias_1.xml are: -- Context docBase=/home/d1 / -- Christopher Schultz-2 wrote This is the first time you mentioned webapp w. Is that the main webapp? Yes. Christopher Schultz-2 wrote Why is that a problem? Actually I realized that even with the previous mechanism I used (using the aliases attribute of the Context element of the w/WEB-INF/context.xml file), I could directly retrieve a resource by typing its exact URL in a browser and without having to identify in any way prior to the retrieval... Christopher Schultz-2 wrote If you want /w/an_alias_1, then re-name your context deployment descriptor: $ mv an_alias_1.xml w\#an_alias_1.xml ... Actually, this is what I did but I didn't want to complicate my answer. Thank you. Christopher Schultz-2 wrote Maybe you just want to make it look like the resource belongs to the webapp. To the Webapp w, yes. Thank you for your comments and your interest. Best regards. -- View this message in context: http://tomcat.10.n6.nabble.com/Tomcat6-Context-aliases-tp4678430p4692232.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Accessing USB drive content from pages served from tomcat6 server
Hello Souvik, BTW, it's not Konstantin who had a problem but me. Try this: 1) Create a usb_1.xml file in /etc/tomcat6/Catalina/localhost/ (the OS being Debian Squeeze) with the following contents: Context docBase=/media/WCF/usb_1 / (Think about removing the extra spaces I added above). 2) (Optional) Restart Tomcat. usb_1.xml should normally be deployed. 3) Then try accessing a resource in /media/WCF/usb_1/ by typing in your browser a URL starting with: http://hostname[:8080]/usb_1/a_resource_in_/media/WCF/usb_1 Best regards. Léa -- View this message in context: http://tomcat.10.n6.nabble.com/Accessing-USB-drive-content-from-pages-served-from-tomcat6-server-tp4684002p4692256.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat6 - Context - aliases
Konstantin Kolinko wrote You should remove the path attribute when Context is defined in an XML file. The name of the xml file itself specifies the path, not the attribute. Indeed. Thank you. Best regards. -- View this message in context: http://tomcat.10.n6.nabble.com/Tomcat6-Context-aliases-tp4678430p4689256.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat6 - Context - aliases
Hello André, André Warnier wrote - you need to tell your webapp where the uploaded files should be stored/retrieved - you cannot do it via an alias under Tomcat v7 Exactly. André Warnier wrote - so instead of an alias, do it via a property in a properties file, which your webapp would read. This is (almost) a pure java solution, which would work under any servlet container of any version. I wish I knew how to do that and yes, I'm interested in an (almost) pure Java solution. May I precise what I did and what already works with Tomcat7: 1) When a user uploads a file to the server running Tomcat, I store the file, for example, in a directory: /home/d1/ 2) In a JSP, this user can view the list of the n files he uploaded: -- a href=/an_alias_1/file_1.txt file_1.txt /a ... a href=/an_alias_1/file_n.txt file_n.txt /a -- 3) In Tomcat7, I used the aliases properties of the Context element in META-INF/context.xml to (magically to me :/), let Tomcat map these addresses: -- /an_alias_1/file_1.txt ... /an_alias_1/file_n.txt -- to their real addresses on the filesystem: -- /home/d1/file_1.txt ... /home/d1/file_n.txt -- so that the user could click on one of these links and retrieve/view the corresponding resource. Of course, I read carefully what you wrote, it looks like I'm really missing something important because I have absolutely no idea how to implement the same mechanism using a properties file as you suggest... Would you be so very kind to to explain a bit more? Thank you and best regards. -- View this message in context: http://tomcat.10.n6.nabble.com/Tomcat6-Context-aliases-tp4678430p4686704.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat6 - Context - aliases
Ok. So, I found a solution, if I can call that a solution. - I created a file an_alias_1.xml in /etc/tomcat6/Catalina/localhost/ (the OS being Debian Squeeze). - Here are the contents of this an_alias_1.xml file: Context path=/an_alias_1 docBase=/home/d1 crossContext=true / - This Configuration Descriptor is automatically deployed once saved. - I suppressed the Webapp w's WEB-INF\context.xml I had created. - I redeployed the Webapp w. = Now, when a user clicks on any link a href=/an_alias_1/file_ i.txt file_ i.txt /a it is successfully retrieved. = What is still problematic to me, is that, when the user clicks on a link, the context or Webapp changes (from w to an_alias_1). The resources which are in /home/d1 are available directly by typing the following URL in a browser: http://hostname:8080/an_alias_1/file_ i.txt and not compulsorily through the Webapp w. Best regards. Ref. - a useful thread on stackoverflow: http://stackoverflow.com/questions/4575562/how-to-set-up-a-different-context-to-point-to-an-external-directory-outside-weba -- View this message in context: http://tomcat.10.n6.nabble.com/Tomcat6-Context-aliases-tp4678430p4687332.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat6 - Context - aliases
Thank you all three for your last answers. André Warnier wrote this might help, in a container- and version-independent way : http://jaitechwriteups.blogspot.de/2007/01/how-to-read-properties-file-in-web.html I'm sorry, no offence... but I don't see how... :/ Pid * wrote Please define 'inside'. In this Web page: http://tomcat.apache.org/tomcat-7.0-doc/config/context.html (look for the first occurrence of the word aliases in this document), there is a description of what the aliases attribute is used for. Excerpt: This attribute provides a list of external locations from which to load resources for this context. When I use the word inside (maybe improperly) I intend to mean the opposite of what is called an external location in the documentation mentionned above. My requirements more clearly now I hope: I just want to know, what is the more basic mechanism which was used in Tomcat6 to do what the aliases attribute of the Context element of the context.xml file permits now to do in Tomcat7. Note 1: I had'nt realized this aliases attribute was container-version-dependent. I wouldn't have used it otherwise. Note 2: Maybe this mechanism has to be implemented directly in the Webapp's source code instead. Note 3: The interesting idea behind this external location notion is to be able to isolate ressources from the Webapp itself and yet being able to refer to them from inside the Webapp. Thank you for helping and best regards. -- View this message in context: http://tomcat.10.n6.nabble.com/Tomcat6-Context-aliases-tp4678430p4681421.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Tomcat6 - Context - aliases
Hello, I've been struggling lately with the aliases attribute of the Context element of the context.xml file. I tested a Webapp with Tomcat7 and it appears to work properly. As a Debian user, Tomcat7 is not yet packaged in the current stable release Squeeze so I installed Tomcat6 instead. Result: the Webapp no longer works properly (as far as the aliases attribute is concerned). When I have a look at the Tomcat6 documentation (http://tomcat.apache.org/tomcat-6.0-doc/config/context.html), it looks like the Context element aliases attribute is not available. 1) Can you confirm it is not? 2) How can I workaround this problem? Thanks for helping. -- View this message in context: http://tomcat.10.n6.nabble.com/Tomcat6-Context-aliases-tp4678428p4678428.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat6 - Context - aliases
Hello, Thank you for your answers. Teppei Yamada wrote 1. What version of Tomcat7 did you test? On a Windows XP machine: Tomcat 7.0.20 On a Debian Squeeze machine: Tomcat 7.0.22 Teppei Yamada wrote 2. Where do you place context.xml in Tomcat6? I don't know you are aware that context.xml placed in yourwebapp/META-INF/context.xml is automatically copied to TOMCAT_HOME/conf/Catalina/(hostname(usually localhost)/yourapp.xml. Once copied, Tomcat6 refers the one in TOMCAT_HOME/conf. Tomcat7.0.26 no longer copies context.xml. I placed context.xml in yourwebapp/META-INF/. I am aware of what you mentionned above. I remember reading that Tomcat6 copies context.xml to TOMCAT_HOME/conf/Catalina/(hostname(usually localhost)/yourapp.xml only the first time the Webapp is deployed. Konstantin Kolinko wrote aliases are a feature added to Tomcat 7. They are not available in earlier versions. The feature is too intrusive to ever consider its backporting. I see. Konstantin Kolinko wrote Install Tomcat 7. Read RUNNING.txt for a start. I prefer not to. As I wrote, Tomcat7 is not packaged yet in Debian stable Squeeze. For security reasons, I want to use only stable, packaged and up-to-date OS and software versions. I there any other workaround... I mean... I guess even before Tomcat7, people needed to declare such aliases. Thank you for your help and best regards. -- View this message in context: http://tomcat.10.n6.nabble.com/Tomcat6-Context-aliases-tp4678430p4678513.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat6 - Context - aliases
Thank you for your advice. And how did people do to declare aliases before the aliases attribute of the Context element was introduced in Tomcat7? -- View this message in context: http://tomcat.10.n6.nabble.com/Tomcat6-Context-aliases-tp4678430p4679060.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat6 - Context - aliases
Pid * wrote Either they did not, or they selected an alternative based on their use-case. I'm sure they did. You'll see below, my requirements are basic. Pid * wrote What is your exact requirement? - Users upload files to the server running Tomcat. - The Webapp stores these file on the hard disk in some directory which has nothing to do neither with the Webapp nor with the Tomcat engine. Let's name it d1. - I needed an alias for the directory d1 to refer to it from inside the Webapp. I created a META-INF/context.xml: ?xml version='1.0' encoding='UTF-8'? Context aliases=quot;/lt;an_alias_1=d1 /Context Of course, it works as expected with Tomcat7. I just want to do something equivalent which works with Tomcat6. Thank you for helping me and best regards. -- View this message in context: http://tomcat.10.n6.nabble.com/Tomcat6-Context-aliases-tp4678430p4679237.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Session expiration - browser -Web application
@Terence : Thank you for your answer. Actually, I extracted the Java code from the JSP and put it in a TLD so that the code is cleaner and more manageable. Best regards, -- Léa -- View this message in context: http://old.nabble.com/Session-expiration---browser--Web-application-tp32780678p32804141.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Session expiration - browser -Web application
Hello, Thank you for reading my post. Maybe my question is not purely related to Tomcat but here is my problem: - a user logs into my Webapp; - his session expires; - if he: - presses the F5 key (browser refresh functionality), - goes back to the previous screen using the browser go back one page button... all that was stored in the session is lost and the Webapp behaviour is uncertain. Instead, I wish I go direct him to the Webapp log in page. My Webapp itself behaves properly. My problem occurs only if the user uses browser functionalities or buttons. I don't know how to deal with that issue. Can you help me? Best regards, -- Léa -- View this message in context: http://old.nabble.com/Session-expiration---browser--Web-application-tp32780678p32780678.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Session expiration - browser -Web application
@Tim : Thank you for your answer. [Tim wrote:] Uncertain is a bit vague. Yes. Ok. This is my understanding which is uncertain then. What happens is what you wrote: a new session for the user with _none_ of the objects from the old session in it. [Tim wrote:] If every page in the web app is supposed to require authentication you need to declare that in web.xml. Can you tell me how? [Tim wrote:] I'm assuming (perhaps incorrectly) you've already got some declaration in there for form authentication? What are you thinking about? Can you be more precise? I guess I should have examined this issue sooner but things are the way they are, aren't they? Thank you and best regards, -- Léa -- View this message in context: http://old.nabble.com/Session-expiration---browser--Web-application-tp32780678p32781413.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Session expiration - browser -Web application
@Christopher : Thank you for your answer. Christopher wrote: The new session created is completely empty. It has nothing to do with the user going back in the history, etc. No, you are right. What I meant is that I was/am managing session expiration inside the Webapp (for instance if the user clicks a button which is inside the Webapp and if the session has expired, I redirect him to the log in page). Christopher wrote: I always try to have enough information in the page (form) so that resuming a workflow after a session timeout is a possibility. I'm sorry but I do not understand what you are explaining me here... A SOLUTION... I THINK. I have found a solution, here it is: for all the JSPs which require a user to be identified (*), I add the following code: % ASessionAttribute aSessionAttribute = null; HttpSession httpSession = null; httpSession = request.getSession(); aSessionAttribute = (ASessionAttribute) httpSession.getAttribute(aSessionAttribute); if(aSessionAttribute == null) { response.sendRedirect(the-log-in-page.jsp); } % Then if a user presses the F5 key and if the session has expired, he is properly redirected to the log in page. Best regards, -- Léa (*) That is to say, in my example, the aSessionAttribute object musn't be null. -- View this message in context: http://old.nabble.com/Session-expiration---browser--Web-application-tp32780678p32782585.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Session expiration - browser -Web application
Héhé. No comment. Have a good week-end and cheers, -- Léa -- View this message in context: http://old.nabble.com/Session-expiration---browser--Web-application-tp32780678p32783180.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Compile, build and prepare Webapp for Tomcat in command line
@Christopher : Thank you for your answer. I wouldn't mind using Maven instead of Ant... yet it doesn't look like I can a find a nice and simple (hello world) example to get started with it (like the one I found for Ant, cf. the link in my previous post)... Actually, I managed to build my Webapp for Tomcat using Ant yesterday... @Terence : Thank you for pointing me to this build.xml example file. Best regards, -- Léa -- View this message in context: http://old.nabble.com/Compile%2C-build-and-prepare-Webapp-for-Tomcat-in-command-line-tp32752945p32758026.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Compile, build and prepare Webapp for Tomcat in command line
Hello, Thank you for reading my post. I am presently programming my Webapps inside Eclipse. I would like to automate the compiling and building of my source code. I need to know which javac, java (and maybe jar) commands I should run from a console to generate everything that is needed for my Webapp to be deployed properly by Tomcat. I want to write a batch file (Windows) and a shell file (Unix) to do this work. Can you give me some advice, indicate me where to look for? For instance, can I retrieve from Eclipse which commands are being launched when the project is being built? Where? All the best, -- Léa -- View this message in context: http://old.nabble.com/Compile%2C-build-and-prepare-Webapp-for-Tomcat-in-command-line-tp32752945p32752945.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Compile, build and prepare Webapp for Tomcat in command line
@Jürgen : Thank you for advising me to use Maven. @Tim : Thank you for advising me to use Ant. I have been following the following tutorial to get introduced to Ant: http://ant.apache.org/manual/tutorial-HelloWorldWithAnt.html I think it's a good one. Now, I am going to have to do something similar with my Webapp... Cheers, -- Léa -- View this message in context: http://old.nabble.com/Compile%2C-build-and-prepare-Webapp-for-Tomcat-in-command-line-tp32752945p32753619.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: WebApp access to a LAN share
Hello again. @awarnier and others. It worked! Thanks. I just want to add that I had to install the smbfs package to be able to mount Windows shares: apt-get install smbfs Best regards, -- Léa -- View this message in context: http://old.nabble.com/WebApp-access-to-a-LAN-share-tp32658680p32683726.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: WebApp access to a LAN share
Hello everyone and thank you very much for your fast answers. @Brian and @Chuck I did configure the WebApp context.xml file to let my WebApp access files elsewhere on my hard disk (S hard disk for now). You are helpful. Thank you. @p Yeah... well, in the end, I'll have to put everything on the same machine. So, for now, I am just interested in the communication between Unix and Windows on the same LAN. @awarnier Very true, thank you. Mounting looks like a good idea. Thanks for detailing the steps. I'll try this as soon as I can (I just do not have S at hand right now). @Stefan Totally agree with the configuration variable recommendation. Thank you all again. I'll come back as soon as possible to let you know how it worked. Best regards, -- Léa -- View this message in context: http://old.nabble.com/WebApp-access-to-a-LAN-share-tp32658680p32661603.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
WebApp access to a LAN share
Hello, Thank you for reading my post. Here is my problem: - I have two machines S and M on the same LAN. - S is a Debian machine running a Tomcat server. - And I have a WebApp W deployed on this Tomcat server. - M is a Windows machine which hosts some files for W. - S and M belong to the same Samba domain. - On M, the WebApp files are stored in a directory: C:\p1\p2\. - p2 is a share. - Somewhere in the WebApp Java code, I have declared a final to store the files path. Here is what I wrote: public static final String s_path = //M/p2/; - Now, when I manipulate the WebApp in such a way a file f.xml located in C:\p1\p2\p3\ has to be opened and read, I get the following error: java.io.FileNotFoundException: /M/p2/p3/f.xml (No such file or directory) My question is: how do I have to declare s_path to properly access, from S (W), those files which are stored on M? (I basically want to have the data on one machine and Tomcat on another machine). Can you help me? Best regards, -- Léa -- View this message in context: http://old.nabble.com/WebApp-access-to-a-LAN-share-tp32658680p32658680.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
URL simplification
Hello, Thank you for reading my post. Here is my question: - Presently, to access my WebApp first page, I have to type in the following URL in a browser: http://hostname-or-ip:8080/my-webapp/ - Instead, I wish I could type in a URL such as: http://my-webapp/ Is it possible? How? And by the way, I don't know what's the name of such an operation. I used the expression URL simplification... Thank you for pointing me in the right direction! Best regards, -- Léa -- View this message in context: http://old.nabble.com/URL-%22simplification%22-tp32622817p32622817.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: URL simplification
Thank you all for your answers. @Mark Yes indeed fundamentally three operations... 1. I guess you can only have one ROOT WebApp not several... It's not ok for me, I have several WebApps I want to treat that way. @Francis Francis wrote: Apache and configure a vhost with proxying That looks promissing. I have Apache installed but I noticed Tomcat is working on its own. (When I stop Apache, Tomcat goes on working properly). I guess I would need to make the two work together... Can you point me to a good ressource/tutorial? @Darril For now, I'm working on Windows. When in production, the WebApp will probably be deployed on a Unix server. For now, no iptables with Windows. Is there a workaround? I'm interested in Francis' proposal... please can you give me more details? Thanks! -- Léa -- View this message in context: http://old.nabble.com/URL-%22simplification%22-tp32622817p32624466.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: WebApps sharing uploaded files
chris wrote: Be careful: if you undeploy the webapp, you will have all those files deleted by Tomcat. Ok. Thank you! André wrote: Thanks. Seen. Lea, do you follow ? Yes, thanks! Ok. I do not properly understand the doc.: http://tomcat.apache.org/tomcat-7.0-doc/config/context.html 1) aliases is an attribute. Is it an attribute of the Context element? 2) I have a context.xml file in META-INF in both w1 and w2. I have tried: 2.A) context.xml ?xml version='1.0' encoding='utf-8'? Context aliases=/attachments=C:\somewhere_1\somewhere_2\somewhere_3 [...] /Context 2.B) I've created a foo.txt file in the directory C:\somewhere_1\somewhere_2\somewhere_3\ 2.C) test_download.html html head titleTest download/title /head body /attachments/foo.txt Foo.txt /body /html When I click the link, I get a 404 error: HTTP Status 404 - /attachments/foo.txt type Status report message /attachments/foo.txt description The requested resource (/attachments/foo.txt) is not available. What am I doing wrong? Thank you and best regards, -- Léa -- View this message in context: http://old.nabble.com/WebApps-sharing-uploaded-files-tp32570911p32595832.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: WebApps sharing uploaded files
Hello. Ok. I found what I was doing wrong and corrected my mistake: added /w1 at the beginning of the href attribute value. See below: 2.C) test_download.html html head titleTest download/title /head body /w1/attachments/foo.txt Foo.txt /body /html Now it works! Best regards, -- Léa -- View this message in context: http://old.nabble.com/WebApps-sharing-uploaded-files-tp32570911p32596193.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: WebApps sharing uploaded files
Hello. Ok. I found what I was doing wrong and corrected my mistake: added /w1 at the beginning of the href attribute value. See below: 2.C) test_download.html html head titleTest download/title /head body /w1/attachments/foo.txt Foo.txt /body /html Now it works! Best regards, -- Léa -- View this message in context: http://old.nabble.com/WebApps-sharing-uploaded-files-tp32570911p32596195.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: WebApps sharing uploaded files
Hello. Ok. I found what I was doing wrong and corrected my mistake: added /w1 at the beginning of the href attribute value. See below: 2.C) test_download.html html head titleTest download/title /head body /w1/attachments/foo.txt Foo.txt /body /html Now it works! Best regards, -- Léa -- View this message in context: http://old.nabble.com/WebApps-sharing-uploaded-files-tp32570911p32596196.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: WebApps sharing uploaded files
Hello André, Do you mean that you are going to create a new JSP for every new file someone may ever upload? No... Or do they always upload the same file f.txt? No... I understand your being puzzled... my bad: the example I posted is oversimple but it works if tested! In reality, the c:choose is dynamic in the JSPs: it is part of a loop which loops through a dynamic list of attachments. And yes you're right, contrary to my original description, there is not a unique uf directory storing both the attachments of w1 and those of w2. Some attachments are in w1\uf1, all the others are in w2\uf2 (it's a partition). That solution is quite good because: - there are no file duplicates, - the JSPs are the same, - I just need a switch inside of them to pick the attachments in the right directory according to a test. What's interesting is that, in the same servlets container, one WebApp has access to another WebApp through /w1/uf1/f.txt /w2/uf2/f.txt type of addressing. Thank you for your interest and best regards, -- Léa -- View this message in context: http://old.nabble.com/WebApps-sharing-uploaded-files-tp32570911p32587503.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: WebApps sharing uploaded files
Hello André, Do you mean that you are going to create a new JSP for every new file someone may ever upload? No... Or do they always upload the same file f.txt? No... I understand your being puzzled... my bad: the example I posted is oversimple but it works if tested! In reality, the c:choose is dynamic in the JSPs: it is part of a loop which loops through a dynamic list of attachments. And yes you're right, contrary to my original description, there is not a unique uf directory storing both the attachments of w1 and those of w2. Some attachments are in w1\uf1, all the others are in w2\uf2 (it's a partition). That solution is quite good because: - there are no file duplicates, - the JSPs are the same, - I just need a switch inside of them to pick the attachments in the right directory according to a test. What's interesting is that, in the same servlets container, one WebApp has access to another WebApp through /w1/uf1/f.txt /w2/uf2/f.txt type of addressing. Thank you for your interest and best regards, -- Léa -- View this message in context: http://old.nabble.com/WebApps-sharing-uploaded-files-tp32570911p32587506.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: WebApps sharing uploaded files
Hello André, Thank you for all these useful advices. Best regards, -- Léa -- View this message in context: http://old.nabble.com/WebApps-sharing-uploaded-files-tp32570911p32582797.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: WebApps sharing uploaded files
Hello, I solved my problem: 1) in WebApp w1, upload files to the directory w1\uf1\, 2) in WebApp w2, upload files to the directory w1\uf2\, 3) then you can have the same JSP foo.jsp for both WebApps. Put one JSP in w1 and another one in w2. The JSP itself contains a switch: c:choose c:when test=a_test a href=/w1/uf1/f.txtLink 1/ a /c:when c:otherwise a href=/w2/uf2/f.txtLink 2/ a /c:otherwise /c:choose Best regards, -- Léa -- View this message in context: http://old.nabble.com/WebApps-sharing-uploaded-files-tp32570911p32583746.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: WebApps sharing uploaded files
Hello Tim, Ok. - I have only one copy of f.txt. - uf1 and uf2 are two distinct directories, the first in w1, the second in w2. - I have one JSP (same code) but two copies of it, the first in w1, the second in w2. f.txt either lives under uf1 xor uf2. Maybe I'm not clear enough... but that's basically what I was trying to do... Thank you for your interest, -- Léa -- View this message in context: http://old.nabble.com/WebApps-sharing-uploaded-files-tp32570911p32584132.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: WebApps sharing uploaded files
Hello André, Thank you for your answer. awarnier wrote: You can define uf wherever you want, as long as Tomcat (and the applications which run under it, like your JSPs) has write access to it. Actually, I already noticed and tried that and my first question is closely linked to my second question about hrefs... (Questions 1) and 2) aren't really two separate questions.) Thank you for your two interesting suggestions: - creating some kind of downloader servlet, - WebDAV which I know nothing about. This is not an academic project. I just made a schematic picture of the situation. Thanks! -- Léa -- View this message in context: http://old.nabble.com/WebApps-sharing-uploaded-files-tp32570911p32573942.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
WebApps sharing uploaded files
Hello, Thank you for reading my post. o I have two WebApps w1 and w2 (under the Tomcat webapps directory). o Both w1 and w2 contain (at least) a JSP which allows to upload files to the server. o Presently, the uploaded files are stored: - in the w1\uf1\ directory for w1, - in the w2\uf2\ directory for w2. (So: each WebApp has its own directory for uploaded files storage). = I need the two Webapps to store their uploaded files in the same directory, say uf. Let's say that: - we have created uf somewhere (where?), - uf contains a successfully uploaded file f.txt, - I have a JSP foo_1.jsp in w1 and a JSP foo_2.jsp in w2. I'd like: - to put an anchor in foo_1.jsp which links to f.txt. -- a href=?_1/f.txtLink 1/ a -- - to put an anchor in foo_2.jsp which links to f.txt. -- a href=?_2/f.txtLink 2/ a -- (I want the files to open properly when the each link is clicked). 1) If it's possible, where shall I create uf? 2) What shall I replace ?_1 and the ?_2 with in the href anchor properties? Please help me. Best regards, -- Léa -- View this message in context: http://old.nabble.com/WebApps-sharing-uploaded-files-tp32570911p32570911.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org