Encoding problems running jsp web pages on Apache Tomcat - eclipse

Sorry for my English.
I'm not a web page developer - I use already created jsp (I can not change them by my own), placing them together with different URL parameters - that way I create some complicated web project.
I have been using Apache Tomcat for a long time and had an error - cyrillic (cp1251) symbols doesn't show well in some places (not everywhere!) of project. Developers of jsp said, that it is a bug and they will fix it. Time goes by, but they do not.
Recently, I have imported EAR as project in Eclipse, created Tomcat server there. Before that I read this article:
http://www.vogella.de/articles/EclipseWTP/article.html
and installed all soft, specified in article to be able to work well with Tomcat project in Eclipse.
And I noticed, that when I publish project to Tomcat Server (created in Eclipse - it has it's own server) I had no errors with encoding! I think this is somehow connected to Eclipse & Eclipse Tomcat Server settings.
Question: Can I copy this settings to a real Tomcat Server (not Eclipse) for correct encoding everywhere? And what are this settings?

I also had a similar problem. My war was running on Eclipse Tomcat but when deployed manually on Tomcat, some web service involving currency symbol was facing encoding issues. Eclipse Indigo has some encoding for server.
This can be seen/edited through Run Configrations -> Common Tab. Changing this attribute produced consistent results for manual deploy and Eclipse deploy. I am not sure what this encoding is of, but it may set JVM's encoding.

Related

IntelliJ Ultimate Equivalent of Eclipse Servers Project (Tomcat)?

I've recently switched from Eclipse to IntelliJ Ultimate and have a question regarding locally testing a Tomcat app from within the IDE.
I have a /META-INF/context.xml file that needs to be deployed with the WAR when it is deployed on our remote Tomcat servers, but because of the way it is setup, this file cannot be used when testing locally.
To handle this in Eclipse, there is a "Servers" project where you can set Tomcat configuration like context.xml, server.xml, catalina.properties, etc. that is ONLY used when running the app from within Eclipse.
I didn't see anything similar to this in IntelliJ. Basically what I need is the capability to use a custom context.xml when running locally in the IDE and a different context.xml when deploying to the real remote servers.
I have a feeling this should be handled in the Tomcat Run Configuration within IntelliJ, but didn't see anything obvious in there.
Thanks!

Tomcat on Eclipse Juno and Luna. One works, the other one doesn't

I am working on JavaEE webprojects using maven for dependencies and so on. The testing environment is Tomcat 7 for eclipse.
Now, when I made the transition to the newer eclipse (Luna) and deploy the webapp on tomcat, the tomcat instance refuses to serve the project. It gives 404 and the request on localhost:8080 doesn't produce any unusual console or log entries except the normal startup output (the exact same as on Juno).
I compared the server access log files located in /.metadata/... and the startup scripts. They are equal. No error messages, and no other clues on why the Luna Tomcat does not work. Don't get me wrong, the server 'works', as it provides a 404 message, it just does not serve the webapp that is deployed.
Does somebody have an idea on how to debug this further, or what the reason for the different behaviour could be? Thanks for any hints or advice.
-a
EDIT:
Just a few things I already did:
- Check and set project root (set to / in both cases)
- One suggestion found via google was to fiddle with the Libraries and Order and Export in Project Settings Build Path. (just move them up and down to get rid of a bug -> did not work)
- In Project Properties, set the targeted runtime to Tomcat 7 (the server in question)
- Reinstall the server
- Copy all configuration from one server path to the other.
- Set the server base path of Luna to the exact same as the working Juno instance (yes, they are in different places)
EDIT2:
Updating Eclipse to the newest version (MARS) did the job. Sadly I will now never know what the cause of the problem was. Luckily everything works again and I can focus on actually doing something :D

lost in deployment: session.getAttribute() returns NULL in some Tomcat configurations

I am experiencing several issues that I can't understand from the first glances. The story is pretty simple, but I guess that the solution is behind some real configuration/deployment problem(s)/inconsistencies.
I have defined a JSP and two servlets. The JSP puts something in the session and the servlets are supposed to fetch the data and to manipulate it. The main symptom is that the servlets do not see the session data, when seeing JSPs in Chrome and Firefox. Interesting, that the JSP/servlets do share the data, when using Eclipse internal browser and also when using Internet Explorer (working on Win7).
Here is a bit long description along with some information (and subsequent symptoms) regarding the local configuration (and, as I believe, there lies the problem): I have installed Eclipse (Helios) under c:\labs\eclipse and unpacked Tomcat (7.0.12) under c:\labs\tomcat. I have also installed the Sysdeo plugin that launches Tomcat.
First, when I launch Tomcat with Sysdeo Eclipse plugin button and then try to access some application-related URL from an external browser - then the main Tomcat page is found, but not the application JSP/pages. However, when I launch Tomcat using the "play/run" Eclipse button (when some JSP page from the Eclipse web project is being selected) - then I can see the rendered JSP page both from Eclipse internal browser AND from any external browser. What is the difference between those two launch modes?
Second, when launching Tomcat via "play/run" Eclipse button only, and calling JSP and servlets either from an internal Eclipse browser or from external Internet Explorer browser, then all the data is being shared correctly by JSP and servlets. However (just for the same launch mode) if I am trying to access the JSP/servlets from external Chrome/Firefox browsers - then the JSP/servlets ARE found, but the data seems NOT to be shared via http session (printed the session id and verified that it is correct).
Third, when I launch Tomcat via "pay/run" button, then I can see the servlet log() printings in Eclipse console ONLY when using the internal Eclipse browser. When JSP/servlets are called from the external browsers - I couldn't find the log printings (but only a few access-related lines in files that reside in Tomcat logs directory).
Tried to summarize the tech issues that look odd to me - I most probably miss some valuable deployment/configuration-related info. Please advice what I am doing wrong and which is the better / correct configuration that will allow the session data to be shared when calling the application resources from all the external browsers. If you need any additional details regarding my configuration/environment - just ask.
Appreciate
Ensure that you're using Eclipse for Java EE developers, not Eclipse for Java developers. It already ships with a Tomcat server plugin builtin. The Sysdeo plugin is pretty old, you don't need it at all and I won't be surprised if that is after all the culprit some of the described problems.
As to running JSP/Servlet using the internal Eclipse browser versus a normal webbrowser, I have myself had bad experiences with the internal browser, I wouldn't recommend to use it for other than "quick testing". However, that it doesn't share the session with another browser is normal behaviour. They do not share the same browser instance anyway. Sessions are not computer-specific, they are browser-specific.
I'd just integrate Tomcat in Eclipse using the EE-provided plugin, start and stop it by the server properties (and not by rightclicking JSP/Servlet and choosing Run or something) and use a real webbrowser to access the pages. To properly getting started with developing JSP/Servlet using Eclipse and Tomcat, I warmly recommend you to use the Coreservlets.com tutorials. At the bottom of our servlets wiki page you can find several direct links.

Tomcat issues inside eclipse

I am very new to Tomcat and web development in general and apologize for what may be a very silly question.
Consider 2 situations:
1.
I start Tomcat outside of Eclipse.
I use eclipse to create a war file.
I deploy it via admin console.
All is ok
2.
I start Tomcat via Eclipse
I can't access admin console
http://localhost:8080/manager/html greets me with 404 error
Same page is behaving properly when Tomcat is started outside of Eclipse
Please advise
Why might the issue be?
Why might the issue be?
You need to configure Eclipse to take control of your Tomcat installation. To do so:
double click on the Tomcat Server in the Servers view
under Server Locations, select Use Tomcat installation
This is illustrated on the screenshot below:
Eclipse creates a new Tomcat configuration separate to your Tomcat installation, in the 'Servers' project. This allows Eclipse to deploy webapps without interfering with anything you've done in your installation (via the manager app or by editing config files manually).
You can reconfigure Eclipse so that it uses the config from your Tomcat installation (see Pascal's answer), or to re-enable the manager app - but read the WTP Tomcat FAQ first as there are good reasons for it working the way it does. I don't recall ever needing to do this - the 'Servers' tab in Eclipse lets you deploy/start/stop/debug/configure apps as required.

What steps are necessary to get Eclipse and a Java servlet container integrated on Ubuntu 9.10?

What's the easiest way for me to get Eclipse running with a Java servlet container on Ubuntu 9.10?
I've tried a number of things, hitting dead ends each time. The best setup would use Ubuntu packages as much as possible, not require running Eclipse as root, and be able to debug running servlets.
Dead ends so far include run-jetty-run, the Sysdeo Tomcat plugin, and Eclipse WTP with tomcat6.
A big part of the problem is that the Ubuntu tomcat6 installation is non-standard, splitting directories such that they're not all in TOMCAT_HOME. Eclipse is also non-standard, and the usual plugin installation methods don't work. I got close by installing the WTP through a PPA, but I stumbled when trying to get it to recognize tomcat.
Ubuntu recently includes a pretty full Eclipse package that you can install via Synaptic or such. But I prefer to download my own.
I download from the Eclipse download site. If I choose Eclipse IDE for Java EE Developers then I have server environments for all Web app containers already built in. If I set up one for Tomcat (in Eclipse), Eclipse will download and install Tomcat for me. It's quite convenient, although I sometimes have trouble finding Tomcat or its files. Eclipse squirrels them away somewhere.
The server setup menus become accessible to you once you create a Web project (not plain Java project).
You should "apt-get install sun-java6-jdk", download and use the Java EE version of Eclipse, and then create a dynamic web project. In the web project create a jsp page, and right click -> "Run -> Run on server" where you may then install a server connector.
Some connectors are included in Java EE, some must be downloaded. Choose the one corresponding to the server you have downloaded and unpacked, and point Eclipse to the directory.
If all succeedes, the JSP page should then show up in a browser served from the started server.