Re: File Content Not Saved To Server
Dear All, First, thank you so much for the reply, Mr. Christopher Schultz. In my program, I want the servlet to load an applet where I can input the file name in a given text field and the file content in a given text area. When the user has input the information, I want to POST the file name and its content from the applet to the servlet. The servlet will then GET the parameters (file name and file content) from the applet and save the file content in C:/temp/ based on the file name that has been input. I do not know whether I pass the parameters from the applet to the servlet correctly. After I input the file name and the file content, 2 files were created by the system: 1. a file with the name null 2. a source code file with a file name from the user input with no content at all. The system should only create one file with a file name and the file content based on the user input. The main problem is that 2 files were created. One question that was asked to me is "Why are you saving a file AND serving a page in the same servlet?" Yes, I'm using the same servlet to save a file and serving a page to save files. What is actually the matter with that approach? Another question was about "What you want is a POST with the content of your file in the request body -- NOT in the request parameters". Can you please elaborate the statement? How should I actually solve this problem? Please explain in detail. I'm really waiting for a prompt reply. Thank you so much. Yours Sincerely, TEH NORANIS Christopher Schultz <[EMAIL PROTECTED]> wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Teh, Teh Noranis Mohd Aris wrote: > I want to save a file name and its content to the computer server at > directory C:/temp/. I've passed the file name and file content > parameter from the applet to the servlet. The problem now is that the > file name is created in the computer server directory but a 'null' is > included in the file content. Can anyone please help me solve the > problem why this is happening? > servletUrl = new URL(servletName + "?filename="+filename+"&teditor="+teditor); > con = servletUrl.openConnection(); > con.setUseCaches(false); > > BufferedReader buf = new BufferedReader(new > InputStreamReader(con.getInputStream())); This isn't what you want to do. What you want is a POST with the content of your file in the request body -- NOT in the request parameters. That isn't to say that your attempt won't work... it's just that there are many limitations on passing information through a URL (such as any maximum URL length limits set by your web server). > HttpSession session = req.getSession(); > PrintWriter out = res.getWriter(); > > out.println(""); > out.println(""); > out.println(""); > out.println("Save File To Server"); > > ... This is a very odd way to do things. Why are you saving a file AND serving a page to save files in the same servlet? > String name = req.getParameter("filename"); > String content = req.getParameter("teditor"); > > String nameFile = "C:/temp/"+name; > FileWriter resultsFile = new FileWriter(nameFile,true); > PrintWriter toFile = new PrintWriter(resultsFile,true); > toFile.println(content); > toFile.close(); So, do you get a file in C:\TEMP\whatever? If so, what is the content of the file. You said "a null"... do you mean a 0 byte file? Or the word "null"? - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFF6KD09CaO5/Lv0PARAph4AJ0RFetzCrvK7kylCLOjfz0s2lNtngCfVgSg 06XYsRJpi0Bn/mEjBsAnp4I= =6KXD -END PGP SIGNATURE- - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - Access over 1 million songs - Yahoo! Music Unlimited.
Choose from one of two JVM
Hello all, I have both jre 1.4.2 and 1.6.1 installed on my gentoo server, running tomcat 5.5.4, and i wonder if there's any possibility of choosing wich jvm will tomcat use. I gess that setting up JAVA_HOME will suffice but just to be sure i would like to have the expert's oppinion. Thank's in advance, Hernâni - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Choose from one of two JVM
http://tomcat.apache.org/tomcat-5.5-doc/setup.html has the info in the section JAVA Location Hernâni Cerqueira wrote: Hello all, I have both jre 1.4.2 and 1.6.1 installed on my gentoo server, running tomcat 5.5.4, and i wonder if there's any possibility of choosing wich jvm will tomcat use. I gess that setting up JAVA_HOME will suffice but just to be sure i would like to have the expert's oppinion. Thank's in advance, Hernâni - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem with context path /webapps
hi mike, try removing the leading "/" in the path... e.g. path="webapps/test" docBase="test" reloadable="true" /> --i believe that's causing your problem, assuming the "webapps" directory is under your tomcat home. hope this helps, mike Mike c wrote: Hi, I am trying to migrate some of our applications currently deployed on Tomcat 4.1 to Tomcat 5.5 and I cannot get any applications that have a context path that starts with /webapps to work. I am getting a 404 error on all these contexts. Does 5.5 not allow a context paths to start webapps? Here is an example context file I've tried. Thanks, Mike - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Informing Tomcat of proxy base URL?
Thought I'd send this again in case anyone knows an answer - I suspect that once a day's worth of posts have gone by, unanswered posts will probably never be answered :) If there's no mechanism for solving this (i.e. passing the proxy base path to Tomcat), it'd be useful to know: I can always configure the proxy such that there is no base path, but if I don't have to, it'd be even better! Cheers, Andy Andy Buckley wrote: I have a Tomcat server providing an application via an Apache proxy. User HTTP requests to http://myserver.example.com/server/ on port 80 get mapped by the proxy to http://localhost:8082, which is set up as a valid Tomcat provider for Apache. So far so good. However, I've noticed problems using Tapestry and DWR (though I don't think they're responsible for the problem), where auto-generated paths from Tomcat apps will look like /foo/bar - this works fine if pointing a browser directly at Tomcat on port 8080, but since the proxy already has a URL path prefix of /server/, these links don't work through the proxy interface. Is there a standard way of informing Tomcat that when accessed on port 8082 it should consider itself either to have a base path starting with /server or to use a base URL of http://myserver.example.com/server? I've already seen references to mod_proxy_html as an Apache module which can do some HTML URL re-writing, but I'm not sure if this is sufficient, since JavaScript libraries like DWR seem to also get some base path information from Tomcat and this is unlikely to be properly handled by mod_proxy_html. Any help would be very welcome - I hope there's a standard solution that I've just been unable to find with Google! Cheers, Andy - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Informing Tomcat of proxy base URL?
> From: Andy Buckley [mailto:[EMAIL PROTECTED] > Subject: Re: Informing Tomcat of proxy base URL? > > If there's no mechanism for solving this (i.e. passing the proxy base > path to Tomcat) Can't say that I've tried it, but the doc speaks of using the proxyName and proxyPort attributes on the appropriate element: http://tomcat.apache.org/tomcat-5.5-doc/proxy-howto.html http://tomcat.apache.org/tomcat-5.5-doc/config/ajp.html - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: PHP + MySql + Apache + Tomcat
hi wayne, first off, thank you! ...you solved my problem with this post.. i was trying for a day to compile a new version of mod_jk so i could use exclusions.. your post made me look into the SetEnvIf operator, and that solved my problem. ..sweet! Now for your issue - try putting quotes around the URI itself, I believe that's your problem with this rule. E.g. : SetEnvIfNoCase Request_URI "/*.php" no-jk ..also, i may advise you to use the "no case" rule... especially since some use both extensions for images on windows platform (e.g. GIF/gif).. the above worked for me on Fedora. Best of luck! hope this helps, mike Wayne Bragg wrote: I have read for hours on the subject but can't quite get a handle on it. My Configuration: Windows XP Pro devside.net Web[Developer] Server Suite 1.94 standard installation ASP,MYSQL,PHP (not cgi) and Tomcat5 All are working fine. I want the final configuration to allow PHP, JSP and MYSQL, (forget about ASP for now, but eventually it also), to all be used in the application or page at the same time. I understand both Apache or Tomcat can handle the PHP and MYSQLFor my purposes, because of previously written applications I would like to have Apache handle both PHP and MYSQL and pass the jsp on to Tomcat. I am failing to grasp exactly what I need to do to this setup to make that work. I've tried some of the configurations and including below but must be missing something. Specifically for the PHP part DocumentRoot /www/webapps/ROOT SetEnvIf Request_URI \.php no-jk SetEnvIf Request_URI \.cgi no-jk JkMount /* ajp13worker1 What else am I going to have to do if I take this approach? Is this the best approach? Is there a simple way to reconfigure what I have? Thanks in advance for any suggestions. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Problem with context path /webapps
> From: "Mike c" [EMAIL PROTECTED] > Subject: Re: Problem with context path /webapps > > I am trying to migrate some of our applications currently > deployed on Tomcat 4.1 to Tomcat 5.5 and I cannot get any > applications that have a context path that starts with > /webapps to work. Depending on where your elements reside, the path and docBase attributes may well be ignored. The path attribute is valid only for elements in server.xml, and docBase only for those in server.xml or stored under conf/Catalina/[host]. Check the doc: http://tomcat.apache.org/tomcat-5.5-doc/config/context.html In particular, pay attention to the bold-face notes, and the description of the path attribute: "The value of this field must not be set except when statically defining a Context in server.xml, as it will be infered [sic] from the filenames used for either the .xml context file or the docBase." - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Informing Tomcat of proxy base URL?
Caldarale, Charles R wrote: From: Andy Buckley [mailto:[EMAIL PROTECTED] Subject: Re: Informing Tomcat of proxy base URL? If there's no mechanism for solving this (i.e. passing the proxy base path to Tomcat) Can't say that I've tried it, but the doc speaks of using the proxyName and proxyPort attributes on the appropriate element: http://tomcat.apache.org/tomcat-5.5-doc/proxy-howto.html http://tomcat.apache.org/tomcat-5.5-doc/config/ajp.html - Chuck If the problem is in-page URLs then I'm not sure this will have much effect. ProxyPassReverse has some effect on headers/cookies but I think it leaves the body alone. There is mod_proxy_html, a 3rd party module that does regexp based rewrites. p THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: mod_jk 1.2.21, apxs, and apache 2.0.54
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Mike, mike spisak wrote: > ...I've spun on this long enough.. how easy is the apache upgrade to > 2.0.58? ..i may want to take you up on the binary offer.. Well, it depends on how you have to install the server itself. If you have to do something weird within your plesk environment, then you might just end up with a broken 2.0.58 environment (in which case, I can give you a binary, but can you really trust me? ;) On the other hand, if you just download the source package and compile and install it "as usual", then you should end up with a proper copy of apxs and you'll be able to build mod_jk no problem. - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFF6ZAa9CaO5/Lv0PARAoiJAJ9Th6Ob3tTPqg9Xk95/QxC0qlrlfQCgiD58 UwRGHxFIKUbe1HbA33UR6cY= =hLC1 -END PGP SIGNATURE- - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
unpackWARs Pros and Cons
Are there any pros and cons running unpackWARs one way or another? It seems like keeping unpackWARs="false" might be a little cleaner (not having to remove expanded directories when deploying a new war file), but I wasn't sure if there were any performance hits associated with running this set to false.
RE: DWR using WAN vs LAN
> From: Wayne Bragg [mailto:[EMAIL PROTECTED] > Subject: DWR using WAN vs LAN > > I installed DWR and it's example chat-demo application works > fine as long as I access it from LAN using > http://localhost:8080/chat-demo/. But if I access it from LAN > http://computer-name/chat-demo/ or WAN > http://wan-ip/chat-demo/. I get a "Chat is not defined" and > "DWRUtil is not defined". What happens if you try http://wan-ip:8080/chat-demo? Without the port number, you're sending the URL to something other than Tomcat that's listening on port 80. > Also, where are these files? They're part of the app, nothing to do with Tomcat itself. > My Configuration: > > Windows XP Pro > devside.net Web[Developer] Server Suite 1.94 > standard installation > ASP,MYSQL,PHP (not cgi) and Tomcat5 > > All are working correctly. If that were really true, would you be asking questions here? > A couple of things worth noting. I'm pretty sure my (cable) > access provider is blocking 80 so I am forwarding ext. 7075 > to int. 80 with Apache still running on 80. What do you mean by "ext." and "int."? Are you inventing synonyms for "port"? By "Apache" (an open-source software organization), do you mean httpd or Tomcat (both are products of said organization)? Is it your router doing the forwarding? If so, external users will need to append :7075 to the host name or IP address to get requests delivered to whatever is listening on port 80. > What is the difference between http://localhost/my-page and > http://localhost:8080/my-page ? Not to belabor the obvious, but the difference is the port number. The former would be sent to port 80 (the default HTTP port), and the latter to 8080, since it's explicitly requested. > Why or how is it one uses Apache and the other appears to be > recognized by Tomcat? If you mean httpd when you say "Apache", that's the default configuration for each - httpd listens on 80, Tomcat on 8080. You're free to change that to anything you want. > Can you not run Tomcat apps from the WAN? Of course you can. Many sites use Tomcat in all sorts of environments. > I haven't been able to find any docs that explain this and > all examples I see for Tomcat use internal > http://localhost:8080 to run jsp. > What am I missing? Some basic education on TCP/IP and a little history, I expect. For many years, Tomcat was not terribly efficient at delivering static content, so it was often front-ended with httpd, listening on port 80. The httpd server would be configured to forward servlet and .jsp requests to Tomcat on port 8080, and handle the rest itself. These days, Tomcat is quite adequate for handling static content, and httpd merely gets in the way (unless you want to do other things with it, such as load-balancing or PHP). To run a stand-alone Tomcat, people normally set it up to listen on port 80, thereby avoiding the need for users to explicitly enter a port number in each URL. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: mod_jk 1.2.21, apxs, and apache 2.0.54
hi Chris, thanks for all your information! you've been helpful.. do I trust you?? ..hhmm.. :-) anyway, my problem was solved by using the SetEnvIfNoCase directive. The main reason i needed an updated jk was for the jkUnMount exclusions.. another post on here pointed me to SetEnvIf - which allowed me the JK mount exclusions I needed.. So now I have tomcat serving servlets, jsps, etc.. and apache taking care of statics and php's.. awesome! Also, FYI- I stumbled on this link--> http://wiki.dspace.org/index.php/ModJk --which had some great ways to get mod_jk compiled.. in addition to the fast path, it talked about using commands like "up2date -i httpd-devel" to get the latest apxs.. and such.. ..its a really good read.. so keep that link in your toolbox. thanks again, mike Christopher Schultz wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Mike, mike spisak wrote: ...I've spun on this long enough.. how easy is the apache upgrade to 2.0.58? ..i may want to take you up on the binary offer.. Well, it depends on how you have to install the server itself. If you have to do something weird within your plesk environment, then you might just end up with a broken 2.0.58 environment (in which case, I can give you a binary, but can you really trust me? ;) On the other hand, if you just download the source package and compile and install it "as usual", then you should end up with a proper copy of apxs and you'll be able to build mod_jk no problem. - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFF6ZAa9CaO5/Lv0PARAoiJAJ9Th6Ob3tTPqg9Xk95/QxC0qlrlfQCgiD58 UwRGHxFIKUbe1HbA33UR6cY= =hLC1 -END PGP SIGNATURE- - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Migration from 5.5.20 to 6.0.10: parser issue on application deployment
Hi, I'm facing a small issue when migrating a production server from 5.5.20 to 6.0.10 (see the exception below). One of the web app running on that server includes xercesImpl.jar and use it through modifying the system property javax.xml.parsers.SAXParserFactory. This was not a problem in 5.5.x, but with 6.0.10, it seems that tomcat loads its instance of the parser after web initializations. It is then affected by the web app that modified the system property. I've been able to 'fix' that by copying the xercesImpl.jar into tomcat lib directory. Shall this be considered as a regression as in that case tomcat configuration is somehow altered by a web app? (in that case I'll fill a bug in bugzilla)) Regards, Etienne GRAVE: Erreur lors du déploiement du répertoire portal de l'application web javax.xml.parsers.FactoryConfigurationError: Provider org.apache.xerces.jaxp.SAXParserFactoryImpl not found at javax.xml.parsers.SAXParserFactory.newInstance(SAXParserFactory.java:134) at org.apache.tomcat.util.digester.Digester.getFactory(Digester.java:487) at org.apache.tomcat.util.digester.Digester.getParser (Digester.java:692) at org.apache.tomcat.util.digester.Digester.getXMLReader(Digester.java:900) at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1581) at org.apache.tomcat.util.modeler.modules.MbeansDescriptorsDiges terSource.execute (MbeansDescriptorsDigesterSource.java:227) at org.apache.tomcat.util.modeler.modules.MbeansDescriptorsDiges terSource.loadDescriptors(MbeansDescriptorsDigesterSource.java:210) at org.apache.tomcat.util.modeler.Registry.load (Registry.java:753) at org.apache.tomcat.util.modeler.Registry.loadDescriptors(Registry.java :865) at org.apache.tomcat.util.modeler.Registry.loadDescriptors(Registry.java :843) at org.apache.tomcat.util.modeler.Registry.findDescriptor (Registry.java :907) at org.apache.tomcat.util.modeler.Registry.findManagedBean(Registry.java :627) at org.apache.tomcat.util.modeler.Registry.findManagedBean(Registry.java :962) at org.apache.tomcat.util.modeler.Registry.registerComponent (Registry.java :793) at org.apache.catalina.core.StandardWrapper.registerJMX(StandardWrapper.java :1801) at org.apache.catalina.core.StandardContext.registerJMX(StandardContext.java :5200) at org.apache.catalina.core.StandardContext.start (StandardContext.java :4374) at org.apache.catalina.core.ContainerBase.addChildInternal( ContainerBase.java:761) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:741) at org.apache.catalina.core.StandardHost.addChild (StandardHost.java:525) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java :920) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java :883) at org.apache.catalina.startup.HostConfig.deployApps (HostConfig.java:492) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java :311) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent ( LifecycleSupport.java:120) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1023) at org.apache.catalina.core.StandardHost.start(StandardHost.java:719) at org.apache.catalina.core.ContainerBase.start (ContainerBase.java:1015) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) at org.apache.catalina.core.StandardService.start(StandardService.java:448) at org.apache.catalina.core.StandardServer.start (StandardServer.java:710) at org.apache.catalina.startup.Catalina.start(Catalina.java:552) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Re: File Content Not Saved To Server
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Teh, Teh Noranis Mohd Aris wrote: > In > my program, I want the servlet to load an applet where I can input > the file name in a given text field and the file content in a given > text area. Just out of curiosity, why do you want an applet to do this when you can just use a "file" input type and upload a file directly? > When the user has input the information, I want to POST > the file name and its content from the applet to the servlet. You are not using a POST. You are using a GET. If you want to use a POST, you will have to write your file content to the request body, instead of putting it into a URL parameter. You had something like this: String url = "http://.../servlet?filename=[name]&content=[contents]";; URLConnection conn = new URL(url).openConnection(); conn.connect(); conn.close(); Instead, you should do something like this: String url = "http://...servlet?filename=[name]";; URLConnection conn = new URL(url).openConnection(); conn.setDoOutput(true); conn.setHeader("Content-Length", contents.length()); conn.connect(); OutputStream out = conn.getOutputStream(); out.write(contents); out.flush(); out.close(); conn.close(); This will put the contents of your file into the request body, instead of in the URL parameters. > I do not know whether I pass the > parameters from the applet to the servlet correctly. To check that the parameters are correct, put something like this into your servlet code: System.out.println("param[filename] = " + request.getParameter("filename")); Also, you might want to print out the fill path of the file you are trying to create. This really ought to do it: File target = new File("C:\\TEMP", filename); FileOutputStream out = new FileOutputStream(target); out.write(contents); out.flush(); out.close(); > After I input > the file name and the file content, 2 files were created by the > system: 1. a file with the name null 2. a source code file with a > file name from the user input with no content at all. I'm not sure how that extra file is being created. Your code only had a single "open" call. Is it possible that "null" was created from an old copy of the code, and you just forgot to delete the file? Finally, don't use a FileWriter unless you know that you are dealing with text. Otherwise, binary files will be corrupted. I'm not sure if that matters to you, but creating a servlet that handles any type of file will be more useful than one that only handles text. > Yes, I'm using > the same servlet to save a file and serving a page to save files. > What is actually the matter with that approach? It just seems that the "save file" servlet should do nothing but save a file. Why have this servlet return any content at all? If I were writing this "system", I would have the following files: applet.html (contains element to serve the applet) SaveFileServlet (saves files, as discussed) When you want to display the applet, just display applet.html. Otherwise, your SaveFileServlet will write to a file called "null" every time you try to display the page (that's probably where your "null" file is coming from). Only call the SaveFileServlet when you actually want to save data. - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFF6b3n9CaO5/Lv0PARApg9AKCHsXSGif7v69laYl4u1DHmGvRrHACbB7cz z2uU32oMdoJKcvL1/9EXf6A= =sF79 -END PGP SIGNATURE- - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Tomcat 5 Install - JAVA_HOME environment variable is not defined correctly
Hi, I recently installed Tomcat 5 following these excellent instructions using the exact same versions that are referenced in the instructions: http://www.meritonlinesystems.com/docs/apache_tomcat_redhat.html When I run the install command I get: [EMAIL PROTECTED] [/usr/local/jakarta-tomcat/bin]# ./startup.sh The JAVA_HOME environment variable is not defined correctly This environment variable is needed to run this program NB: JAVA_HOME should point to a JDK not a JRE >From the instructions I did the following: ** Set the JAVA_HOME environment variable, by modifying /etc/profile so it includes the following: JAVA_HOME="/usr/java/j2sdk1.4.2" export JAVA_HOME /etc/profile is run at startup and when a user logs into the system, so you will need to log out and log back in for JAVA_HOME to be defined. exit su - However, when I check the [EMAIL PROTECTED] [~]# echo $JAVA_HOME /usr/local/jdk [EMAIL PROTECTED] [~]# *** it appears that "JAVA_HOME" still points to the wrong directory. I have repeatedly tried to reset the JAVA_HOME variable and searched for a solution on Google & MARC but I am hitting a wall. -- From the root level the Java (j2sdk1.4.2) is installed in the /usr/java directory /usr/local/jdk -- Tomcat is installed in the /usr/local/jakarta-tomcat directory. OS: CentOS I am installing this on a Virtual Private Server (VPS) at a hosted facility. Any tips/suggestions would be greatly appreciated. Paul
Re: Tomcat 5 Install - JAVA_HOME environment variable is not defined correctly
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Paul, Paul Pearce wrote: > I recently installed Tomcat 5 following these excellent instructions using > the exact same versions that are referenced in the instructions: > > http://www.meritonlinesystems.com/docs/apache_tomcat_redhat.html > > When I run the install command I get: FYI this is not an "install" command. It's a "startup" scripe. > [EMAIL PROTECTED] [/usr/local/jakarta-tomcat/bin]# ./startup.sh > > The JAVA_HOME environment variable is not defined correctly This environment > variable is needed to run this program > > NB: JAVA_HOME should point to a JDK not a JRE Okay, so JAVA_HOME doesn't point to the right place. No problem. > Set the JAVA_HOME environment variable, by modifying /etc/profile so it > includes the following: > > JAVA_HOME="/usr/java/j2sdk1.4.2" > export JAVA_HOME Sounds good. > exit > su - I'm not sure if "su -" counts as a login shell (and might skip /etc/profile). You might also want to: # source /etc/profile > However, when I check the > > [EMAIL PROTECTED] [~]# echo $JAVA_HOME > > /usr/local/jdk Is this what you get when you completely logout and then ssh back into the server? If JAVA_HOME is set to /usr/local/jdk, then perhaps your java installation has modified /etc/profile or another environmental setup script to set this value. If you modified /etc/profile and set this value /earlier/ in the file, then the "bad" value will clobber yours and it will not look like your EXPORT is working properly. Try looking for other places where JAVA_HOME is set in /etc. Try /etc/profile, /etc/bash_*, /etc/csh*, /etc/login, etc. You could also try your own login scripts (~/.bash_*, ~/.login, etc.). > it appears that "JAVA_HOME" still points to the wrong directory. You could always try this: $ export JAVA_HOME=/usr/java/j2sdk1.4.2 $ /usr/local/jakarta-tomcat/bin/startup.sh This would at least prove to you that, when JAVA_HOME is correctly set, that Tomcat starts up properly. After you have verified that, you can move on to try to set JAVA_HOME properly all the time. Why do you have both Java 1.4 and JDK 1.5 installed at the same time? - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFF6cyD9CaO5/Lv0PARAj+BAJ9uWp7OfSiL2tPRe7oItWBPIafCqQCdGkWQ A04+rpj4amviDvv7cXN8BBE= =w5xD -END PGP SIGNATURE- - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Migration from 5.5.20 to 6.0.10: parser issue on application deployment
> From: Etienne Giraudy [mailto:[EMAIL PROTECTED] > Subject: Migration from 5.5.20 to 6.0.10: parser issue on > application deployment > > One of the web app running on that server includes > xercesImpl.jar and use it through modifying the system > property javax.xml.parsers.SAXParserFactory. That behavior looks rather questionable to me. Having a webapp modify a global property that has the potential of affecting everything running in that JVM - including other webapps and the container - seems like a very risky strategy, raising serious compatibility and operability issues. The fact that it happened to work in one version of one container doesn't imply that it's an appropriate thing to do. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
DWR using WAN vs LAN
Chuck, I can't begin to thank you enough for you reply. I know some of these questions are borderline inappropriate for this mailing-list subject but they, at least loosely, apply. My newbism is defiantly showing. First, the idiot I am I didn't realize port 80 was 80 and 8080 was 8080. I thought they somehow referred to the same port, du! That explains allot of my confusion! With that said >What happens if you try http://wan-ip:8080/chat-demo? Without the port >number, you're sending the URL to something other than Tomcat that's >listening on port 80. this is where the confusion starts. Your telling me to send the URL to "http://wan-ip:8080/chat-demo"; but then you say "you're sending the URL to something other than Tomcat that's listening on port 80" Here I go getting confused again, what is it 80 or 8080? Or was that just a slip on your part? I'm going to assume the latter unless you tell me otherwise. Either way, I get "page not found" if I use anything other than http://localhost:8080/chat-demo which works perfectly or I can get to it at least run the page with http://wan-ip/chat-demo because I have an "Alias /chat-demo" in Apache config serving on port 80, but that's when I get the "Chat is not defined" error. I though maybe my provider was blocking port 8080 so I even tried http://localhost:7077/chat-demo which my router is redirecting to 8080. That is what I have to do for Apache and that's what I was talking about when I said > A couple of things worth noting. I'm pretty sure my (cable) > access provider is blocking 80 so I am forwarding ext. 7075 ext. = web browser pointing to port 7075 and > to int. 80 with Apache still running on 80. int = router redirect to port 80. I was referring to my router redirecting port 7075 to port 80. So if I am understanding this correctly I am not getting through to the Tomcat server from the WAN. I also can't get through to Tomcat using http://computer-name:8080/ I can only get through using localhost:8080. I checked XP firewall and have 7077 port (redirected to 8080) opened. Any idea why I cant get to it? > > > > Also, where are these files? "They're part of the app, nothing to do with Tomcat itself." I realize that they are part of the app. This question was because I though maybe something to do with the paths to them was causing the error. That's because I am not to familiar (yet) with the file/directory structure regarding Tomcat apps directory and was able to find > > but not > which is why I said >If they are in the dwr.jar file then I am beginning to understand the >organization >except the "src='/chat-demo/dwr/interface/Chat.js'" file isn't in that jar. >If it is in the chat.class file then I think I am really beginning to >understand the organization. If this is correct then it still leads me back to I'm not getting through to Tomcat from WAN or for some reason using my computer-name either. > My Configuration: > Windows XP Pro > devside.net Web[Developer] Server Suite 1.94 > standard installation > ASP,MYSQL,PHP (not cgi) and Tomcat5 > All are working correctly. "If that were really true, would you be asking questions here?" What I meant is they are all working correctly independently so to speak. They may even be working perfectly but not configured correctly to allow PHP, MySQL, ASP and Java to work on the same page at the same time which is what I am ultimately trying to accomplish. "Is it your router doing the forwarding? If so, external users will need to append :7075 to the host name or IP address to get requests delivered to whatever is listening on port 80." Yes it's the router doing the forwarding. I got that and knew that. Sorry I explained it poorly. If you mean httpd when you say "Apache", Yes, I realize Apache Org develops both Tomcat and httpd and I was referring to httpd when I was saying Apache (which most people do). Again sorry for the incorrect reference. > Can you not run Tomcat apps from the WAN? "Of course you can. Many sites use Tomcat in all sorts of environments." That answers that question, thanks. > What am I missing? "Some basic education on TCP/IP and a little history, I expect. For many years, Tomcat was not terribly efficient at delivering static content, so it was often front-ended with httpd, listening on port 80. The http server would be configured to forward servlet and .jip requests to Tomcat on port 8080, and handle the rest itself. These days, Tomcat is quite adequate for handling static content, and httpd merely gets in the way (unless you want to do other things with it, such as load-balancing or PHP). To run a stand-alone Tomcat, people normally set it up to listen on port 80, thereby avoiding the need for users to explicitly enter a port number in each URL." This goes to the heart of the matter. I have apps that rely heavily on PHP and MySql. I've read (see I do read, ha!) that " front-ending with httpd" is what I want to do. I know I can
Re: DWR using WAN vs LAN
You may want to limit your question to one topic at a time. I've read through your post and it is difficult to tell what your real problem is. The networking issue, I assume you've already been informed, doesn't belong to the mailing list. Tomcat/Apache/PHP can all work together depending on how you send up your application. Apache's mod_jk is how you make Apache and tomcat work together. If you create an app that uses both Tomcat(jsp) and PHP then you'll have to manage two separate sessions, though that shouldn't be terribly difficult to do. Tomcat is configured to run on 8080 by default you can change that to 80 by editing the server.xml file. All http traffic that doesn't specify a port automatically go to 80. To access your computer from the Internet you'll need to first open the port on your router or remove the computer you want to access from the router's DMZ (not recommended). Make sure you use your actual IP which you can determine by typing "what's my IP " on google and following the first link. Hope this helps. On 3/3/07, Wayne Bragg <[EMAIL PROTECTED]> wrote: Chuck, I can't begin to thank you enough for you reply. I know some of these questions are borderline inappropriate for this mailing-list subject but they, at least loosely, apply. My newbism is defiantly showing. First, the idiot I am I didn't realize port 80 was 80 and 8080 was 8080. I thought they somehow referred to the same port, du! That explains allot of my confusion! With that said >What happens if you try http://wan-ip:8080/chat-demo? Without the port >number, you're sending the URL to something other than Tomcat that's >listening on port 80. this is where the confusion starts. Your telling me to send the URL to "http://wan-ip:8080/chat-demo"; but then you say "you're sending the URL to something other than Tomcat that's listening on port 80" Here I go getting confused again, what is it 80 or 8080? Or was that just a slip on your part? I'm going to assume the latter unless you tell me otherwise. Either way, I get "page not found" if I use anything other than http://localhost:8080/chat-demo which works perfectly or I can get to it at least run the page with http://wan-ip/chat-demo because I have an "Alias /chat-demo" in Apache config serving on port 80, but that's when I get the "Chat is not defined" error. I though maybe my provider was blocking port 8080 so I even tried http://localhost:7077/chat-demo which my router is redirecting to 8080. That is what I have to do for Apache and that's what I was talking about when I said > A couple of things worth noting. I'm pretty sure my (cable) > access provider is blocking 80 so I am forwarding ext. 7075 ext. = web browser pointing to port 7075 and > to int. 80 with Apache still running on 80. int = router redirect to port 80. I was referring to my router redirecting port 7075 to port 80. So if I am understanding this correctly I am not getting through to the Tomcat server from the WAN. I also can't get through to Tomcat using http://computer-name:8080/ I can only get through using localhost:8080. I checked XP firewall and have 7077 port (redirected to 8080) opened. Any idea why I cant get to it? > > > > Also, where are these files? "They're part of the app, nothing to do with Tomcat itself." I realize that they are part of the app. This question was because I though maybe something to do with the paths to them was causing the error. That's because I am not to familiar (yet) with the file/directory structure regarding Tomcat apps directory and was able to find > > but not > which is why I said >If they are in the dwr.jar file then I am beginning to understand the organization >except the "src='/chat-demo/dwr/interface/Chat.js'" file isn't in that jar. >If it is in the chat.class file then I think I am really beginning to understand the organization. If this is correct then it still leads me back to I'm not getting through to Tomcat from WAN or for some reason using my computer-name either. > My Configuration: > Windows XP Pro > devside.net Web[Developer] Server Suite 1.94 > standard installation > ASP,MYSQL,PHP (not cgi) and Tomcat5 > All are working correctly. "If that were really true, would you be asking questions here?" What I meant is they are all working correctly independently so to speak. They may even be working perfectly but not configured correctly to allow PHP, MySQL, ASP and Java to work on the same page at the same time which is what I am ultimately trying to accomplish. "Is it your router doing the forwarding? If so, external users will need to append :7075 to the host name or IP address to get requests delivered to whatever is listening on port 80." Yes it's the router doing the forwarding. I got that and knew that. Sorry I explained it poorly. If you mean httpd when you say "Apache", Yes, I realize Apache Org develops both Tomcat and httpd and I was referring to httpd when I was saying Apache (which most people do). Again sorry for the incorre
Re: DWR using WAN vs LAN
You may want to limit your question to one topic at a time. Sorry for any confusion. Tomcat/Apache/PHP can all work together depending on how you send up your application. Apache's mod_jk is how you make Apache and tomcat work together. < Tomcat is configured to run on 8080 by default you can change that to 80 by editing the server.xml file. All http traffic that doesn't specify a port automatically go to 80. To access your computer from the Internet you'll need to first open the port on your router or remove the computer you want to access from the router's DMZ (not recommended). Make sure you use your actual IP which you can determine by typing "what's my IP " on google and following the first link. I am aware of all this! Thanks for the reply. All the explanation I have given was to help avoid these unnecessary emails, but I guess that didn't work. I have two topics and I need answers to both. I thought they were related but I can now see they are independent from one another. One topic led me to the second one or vice versa. Topic or question 1 - This is not a router or network question. I know how to configure the router and network. My Tomcat server doesn't recognize any requests that are not coming specifically from "localhost:8080". Not even from "my-computer-name:8080" which I thought was the same thing. Is it suppose to do that? If not does anyone have a clue as to why it isn't or how to fix it? If this is not an appropriate question for this list then I guess I need the admin to let me know that. I don't see how it's not. But apologies if it is. Topic or question 2 - Starting with the Devside.net Web[Developer] Server Suite 1.94 standard default installation, does anyone know the steps needed to configure "HTTPD" to handle the PHP and "TOMCAT" to handle the Java all at the same time, from the same page and the same directories? Is so how? If you create an app that uses both Tomcat(jsp) and PHP then you'll have to manage two separate sessions, though that shouldn't be terribly difficult to do. This relates to the second question and is what I need help with. I could use the steps necessary to accomplish this. I know the code below is part of it. DocumentRoot /www/webapps/ROOT SetEnvIf Request_URI \.php no-jk SetEnvIf Request_URI \.cgi no-jk JkMount /* ajp13worker1 "try putting quotes around the URI itself, I believe that's your problem with this rule. E.g. : SetEnvIfNoCase Request_URI "/*.php" no-jk ..also, i may advise you to use the "no case" rule..." Mike, thank you for your reply. I haven't tried that yet but will work the second question as soon as I can get Tomcat to recognize something other than localhost. I appreciate it. I assume you've already been informed, doesn't belong to the mailing list. If these questions are not appropriate for this list then I guess I need the admin to let me know that. I don't see how it's not. But apologies if it is. - Original Message - From: "EDMOND KEMOKAI" <[EMAIL PROTECTED]> To: "Tomcat Users List" Sent: Saturday, March 03, 2007 4:41 PM Subject: Re: DWR using WAN vs LAN I've read through your post and it is difficult to tell what your real problem is. The networking issue, I assume you've already been informed, doesn't belong to the mailing list. Tomcat/Apache/PHP can all work together depending on how you send up your application. Apache's mod_jk is how you make Apache and tomcat work together. If you create an app that uses both Tomcat(jsp) and PHP then you'll have to manage two separate sessions, though that shouldn't be terribly difficult to do. Tomcat is configured to run on 8080 by default you can change that to 80 by editing the server.xml file. All http traffic that doesn't specify a port automatically go to 80. To access your computer from the Internet you'll need to first open the port on your router or remove the computer you want to access from the router's DMZ (not recommended). Make sure you use your actual IP which you can determine by typing "what's my IP " on google and following the first link. Hope this helps. On 3/3/07, Wayne Bragg <[EMAIL PROTECTED]> wrote: Chuck, I can't begin to thank you enough for you reply. I know some of these questions are borderline inappropriate for this mailing-list subject but they, at least loosely, apply. My newbism is defiantly showing. First, the idiot I am I didn't realize port 80 was 80 and 8080 was 8080. I thought they somehow referred to the same port, du! That explains allot of my confusion! With that said >What happens if you try http://wan-ip:8080/chat-demo? Without the port >number, you're sending the URL to something other than Tomcat that's >listening on port 80. this is where the confusion starts. Your telling me to send the URL to "http://wan-ip:8080/chat-demo"; but then you say "you're sending the URL to something other than Tomcat that's listening on port 80" Here I go
Removing work directory
I'm wondering if anyone has run into a problem where the jsp pages under the work directory do not get updated when a new version of the applicaiton is deployed. We find that we have to delete everything under the work directory so that tomcat is forced to re-create everything. This seems a little odd and I would like to remove this step in our release process if possible. I am using tomcat 5.5.20 on RHEL 4.0 Thanks
Re: unpackWARs Pros and Cons
Jim Goodspeed wrote: Are there any pros and cons running unpackWARs one way or another? It seems like keeping unpackWARs="false" might be a little cleaner (not having to remove expanded directories when deploying a new war file), but I wasn't sure if there were any performance hits associated with running this set to false. I've been running with packed WARs for a while, and just ran into an issue with Spring's log4jContextListener. It demands that the war be unpacked so it can reference the application root as an absolute pathname. Tsk! I agree that leaving them packed is neater, and I like not having to worry about stale files in an exploded app directory, but I'm careful to delete the exploded directory most of the time anyway. Having them unpacked should have a slight performance advantage because the files don't have to be searched and unpacked from the WAR when they're referenced. Best regards, Mojo -- Morris Jones Monrovia, CA http://www.whiteoaks.com Old Town Astronomers: http://www.otastro.org - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
AJP flush packets (tomcat 6.0.10 and mod_jk 1.2.21)
Hi, in mod_jk's logfile, i don't see any flush-packets (= write packet of length 0) and so apache doesn't do flushing either. Of course the old "JkOption +FlushPackets" works. But the new flush-packets would be much nicer. I think, that i might have to enable the flush-packets thing within tomcat. Any ideas? Thanks, Sven signature.asc Description: OpenPGP digital signature
Re: DWR using WAN vs LAN
After all this, and with a new understanding of how httpd and tomcat work together, I was reading the documentation I have on my installation of Tomcat, again. It is setup so the "native server" is on port 8080 and the "jk connector" is through httpd 80 or however you'd say that. All the example apps that came with the Tomcat installation work through both the native server (8080) and the jk connector (80). So I installed DWR, using it's defaults, to be able to use the AJAX calls. All of DWR's examples only work through the native server localhost:8080/dwr/. If I try to run them using the tk connector localhost:80/dwr/ anytime they need to call the supporting jar and class files they get the "[$variable] is not defined" error. Any idea what is causing this? Is it something to do with the paths to these supporting files? Also I still can't connect, at all, to the native server through anything other than localhost:8080. It's not a network or router issue, they are configured correctly. Even my-computer-name:8080 won't connect to the native server. Any ideas what's up with that? I apologize for not asking these questions this way from the start. - Original Message - From: "Wayne Bragg" <[EMAIL PROTECTED]> To: "Tomcat Users List" Sent: Saturday, March 03, 2007 6:13 PM Subject: Re: DWR using WAN vs LAN You may want to limit your question to one topic at a time. Sorry for any confusion. Tomcat/Apache/PHP can all work together depending on how you send up your application. Apache's mod_jk is how you make Apache and tomcat work together. < Tomcat is configured to run on 8080 by default you can change that to 80 by editing the server.xml file. All http traffic that doesn't specify a port automatically go to 80. To access your computer from the Internet you'll need to first open the port on your router or remove the computer you want to access from the router's DMZ (not recommended). Make sure you use your actual IP which you can determine by typing "what's my IP " on google and following the first link. I am aware of all this! Thanks for the reply. All the explanation I have given was to help avoid these unnecessary emails, but I guess that didn't work. I have two topics and I need answers to both. I thought they were related but I can now see they are independent from one another. One topic led me to the second one or vice versa. Topic or question 1 - This is not a router or network question. I know how to configure the router and network. My Tomcat server doesn't recognize any requests that are not coming specifically from "localhost:8080". Not even from "my-computer-name:8080" which I thought was the same thing. Is it suppose to do that? If not does anyone have a clue as to why it isn't or how to fix it? If this is not an appropriate question for this list then I guess I need the admin to let me know that. I don't see how it's not. But apologies if it is. Topic or question 2 - Starting with the Devside.net Web[Developer] Server Suite 1.94 standard default installation, does anyone know the steps needed to configure "HTTPD" to handle the PHP and "TOMCAT" to handle the Java all at the same time, from the same page and the same directories? Is so how? If you create an app that uses both Tomcat(jsp) and PHP then you'll have to manage two separate sessions, though that shouldn't be terribly difficult to do. This relates to the second question and is what I need help with. I could use the steps necessary to accomplish this. I know the code below is part of it. DocumentRoot /www/webapps/ROOT SetEnvIf Request_URI \.php no-jk SetEnvIf Request_URI \.cgi no-jk JkMount /* ajp13worker1 "try putting quotes around the URI itself, I believe that's your problem with this rule. E.g. : SetEnvIfNoCase Request_URI "/*.php" no-jk ..also, i may advise you to use the "no case" rule..." Mike, thank you for your reply. I haven't tried that yet but will work the second question as soon as I can get Tomcat to recognize something other than localhost. I appreciate it. I assume you've already been informed, doesn't belong to the mailing list. If these questions are not appropriate for this list then I guess I need the admin to let me know that. I don't see how it's not. But apologies if it is. - Original Message - From: "EDMOND KEMOKAI" <[EMAIL PROTECTED]> To: "Tomcat Users List" Sent: Saturday, March 03, 2007 4:41 PM Subject: Re: DWR using WAN vs LAN I've read through your post and it is difficult to tell what your real problem is. The networking issue, I assume you've already been informed, doesn't belong to the mailing list. Tomcat/Apache/PHP can all work together depending on how you send up your application. Apache's mod_jk is how you make Apache and tomcat work together. If you create an app that uses both Tomcat(jsp) and PHP then you'll have to manage two separate sessions, though that shouldn't b
Re: File Content Not Saved To Server
Dear All, Thank you so much for the explanation, Mr. Christopher Schultz. I understand that by just using a "file" input type, I can upload a file directly. In fact, I already construct the program and it is already working. However, I choose to use applet to get the advantage of Java GUI programming, which is event-driven. Actually, the save file module is only part of the system. I'm going to try what has been suggested and I will get to you soon. Thank you so much. Yours Sincerely, TEH NORANIS Christopher Schultz <[EMAIL PROTECTED]> wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Teh, Teh Noranis Mohd Aris wrote: > In > my program, I want the servlet to load an applet where I can input > the file name in a given text field and the file content in a given > text area. Just out of curiosity, why do you want an applet to do this when you can just use a "file" input type and upload a file directly? > When the user has input the information, I want to POST > the file name and its content from the applet to the servlet. You are not using a POST. You are using a GET. If you want to use a POST, you will have to write your file content to the request body, instead of putting it into a URL parameter. You had something like this: String url = "http://.../servlet?filename=[name]&content=[contents]";; URLConnection conn = new URL(url).openConnection(); conn.connect(); conn.close(); Instead, you should do something like this: String url = "http://...servlet?filename=[name]";; URLConnection conn = new URL(url).openConnection(); conn.setDoOutput(true); conn.setHeader("Content-Length", contents.length()); conn.connect(); OutputStream out = conn.getOutputStream(); out.write(contents); out.flush(); out.close(); conn.close(); This will put the contents of your file into the request body, instead of in the URL parameters. > I do not know whether I pass the > parameters from the applet to the servlet correctly. To check that the parameters are correct, put something like this into your servlet code: System.out.println("param[filename] = " + request.getParameter("filename")); Also, you might want to print out the fill path of the file you are trying to create. This really ought to do it: File target = new File("C:\\TEMP", filename); FileOutputStream out = new FileOutputStream(target); out.write(contents); out.flush(); out.close(); > After I input > the file name and the file content, 2 files were created by the > system: 1. a file with the name null 2. a source code file with a > file name from the user input with no content at all. I'm not sure how that extra file is being created. Your code only had a single "open" call. Is it possible that "null" was created from an old copy of the code, and you just forgot to delete the file? Finally, don't use a FileWriter unless you know that you are dealing with text. Otherwise, binary files will be corrupted. I'm not sure if that matters to you, but creating a servlet that handles any type of file will be more useful than one that only handles text. > Yes, I'm using > the same servlet to save a file and serving a page to save files. > What is actually the matter with that approach? It just seems that the "save file" servlet should do nothing but save a file. Why have this servlet return any content at all? If I were writing this "system", I would have the following files: applet.html (contains element to serve the applet) SaveFileServlet (saves files, as discussed) When you want to display the applet, just display applet.html. Otherwise, your SaveFileServlet will write to a file called "null" every time you try to display the page (that's probably where your "null" file is coming from). Only call the SaveFileServlet when you actually want to save data. - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFF6b3n9CaO5/Lv0PARApg9AKCHsXSGif7v69laYl4u1DHmGvRrHACbB7cz z2uU32oMdoJKcvL1/9EXf6A= =sF79 -END PGP SIGNATURE- - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - Never miss an email again! Yahoo! Toolbar alerts you the instant new Mail arrives. Check it out.
Re: DWR using WAN vs LAN
You have 2 problems Separate them out. 1) "Also I still can't connect, at all, to the native server through anything other than localhost:8080. It's not a network or router issue, they are configured correctly. Even my-computer-name:8080 won't connect to the native server. Any ideas what's up with that? " This is purely a Tomcat, router, firewall issue Start a new question in the forum about this with some log details. When it won't connect, what are the symptoms? Can you see the attempt (destination port:8080) in the firewall logs? Is Tomcat seeing anything trying to talk to it? What if you telnet to my-computer-name 8080; do you get a connection that looks the same as telnet to localhost:8080. 2) Once you get 1) working, you can start on the httpd=>jk=>Tomcat. Start a new thread with this once you have 1) solved. Look in the httpd logs to see if the httpd server is passing it on. You can also use the Tomcat manager and logs to see if its AJP connector is getting hit. Depending on what the logs show, you may have questions for the httpd forum. You may want to check to be sure that the 8009 (AJP) port is set up in Tomcat (server.xml) and that this is the port used by jk on the httpd side. 8080 is for browsers; 8009 is for AJP which is a whole different set of messages. Is jk trying to connect to localhost or my-computer-name? By putting two unrelated questions in the same forum thread, you are making it more confusing than it needs to be. Wayne Bragg wrote: After all this, and with a new understanding of how httpd and tomcat work together, I was reading the documentation I have on my installation of Tomcat, again. It is setup so the "native server" is on port 8080 and the "jk connector" is through httpd 80 or however you'd say that. All the example apps that came with the Tomcat installation work through both the native server (8080) and the jk connector (80). So I installed DWR, using it's defaults, to be able to use the AJAX calls. All of DWR's examples only work through the native server localhost:8080/dwr/. If I try to run them using the tk connector localhost:80/dwr/ anytime they need to call the supporting jar and class files they get the "[$variable] is not defined" error. Any idea what is causing this? Is it something to do with the paths to these supporting files? Also I still can't connect, at all, to the native server through anything other than localhost:8080. It's not a network or router issue, they are configured correctly. Even my-computer-name:8080 won't connect to the native server. Any ideas what's up with that? I apologize for not asking these questions this way from the start. - Original Message - From: "Wayne Bragg" <[EMAIL PROTECTED]> To: "Tomcat Users List" Sent: Saturday, March 03, 2007 6:13 PM Subject: Re: DWR using WAN vs LAN You may want to limit your question to one topic at a time. Sorry for any confusion. Tomcat/Apache/PHP can all work together depending on how you send up your application. Apache's mod_jk is how you make Apache and tomcat work together. < Tomcat is configured to run on 8080 by default you can change that to 80 by editing the server.xml file. All http traffic that doesn't specify a port automatically go to 80. To access your computer from the Internet you'll need to first open the port on your router or remove the computer you want to access from the router's DMZ (not recommended). Make sure you use your actual IP which you can determine by typing "what's my IP " on google and following the first link. I am aware of all this! Thanks for the reply. All the explanation I have given was to help avoid these unnecessary emails, but I guess that didn't work. I have two topics and I need answers to both. I thought they were related but I can now see they are independent from one another. One topic led me to the second one or vice versa. Topic or question 1 - This is not a router or network question. I know how to configure the router and network. My Tomcat server doesn't recognize any requests that are not coming specifically from "localhost:8080". Not even from "my-computer-name:8080" which I thought was the same thing. Is it suppose to do that? If not does anyone have a clue as to why it isn't or how to fix it? If this is not an appropriate question for this list then I guess I need the admin to let me know that. I don't see how it's not. But apologies if it is. Topic or question 2 - Starting with the Devside.net Web[Developer] Server Suite 1.94 standard default installation, does anyone know the steps needed to configure "HTTPD" to handle the PHP and "TOMCAT" to handle the Java all at the same time, from the same page and the same directories? Is so how? If you create an app that uses both Tomcat(jsp) and PHP then you'll have to manage two separate sessions, though that shouldn't be terribly difficult to do. This relates to the second question and is what I
Re: Migration from 5.5.20 to 6.0.10: parser issue on application deployment
On 3/3/07, Caldarale, Charles R <[EMAIL PROTECTED]> wrote: > From: Etienne Giraudy [mailto:[EMAIL PROTECTED] > Subject: Migration from 5.5.20 to 6.0.10: parser issue on > application deployment > > One of the web app running on that server includes > xercesImpl.jar and use it through modifying the system > property javax.xml.parsers.SAXParserFactory. That behavior looks rather questionable to me. Having a webapp modify a global property that has the potential of affecting everything running in that JVM - including other webapps and the container - seems like a very risky strategy, raising serious compatibility and operability issues. The fact that it happened to work in one version of one container doesn't imply that it's an appropriate thing to do. I guess that the point that is questionnable here is the way the API is designed: modifying the system property 'legal' and, AFAIK, it is the only way to choose the parser implementation we want to use (http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/parsers/SAXParser.html). From that point of view, shouldn't Tomcat protect itself against bad-designed standard APIs usage? Etienne - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]