Servlet libraries are not defined in Eclipse - eclipse

I am trying to make a simple servlet in Eclipse. But including the following libraries generates errors as if they were not defined in Eclipse.
import javax.servlet.*;
import javax.servlet.http.*;
How to have them recognised and defined?

Please add servlet-api.jar in classpath of your project.if you are using tomcat server, then it should be present in ${CATALINA_HOME}/lib

Be sure you are doing the right way:
If you are using the Classic version of Eclipse, then you must donwload the Web Tools Platform.
If you have an Eclipse Java EE Edition, then there is already installed the necessary plugins.
Create a new Dynamic Web Project: Menu New > Project > Dynamic Web Project.
Fill all values you want for the new project.
Do right click on the project and select New Servlet.
Last step creates a new Class file that is a servlet class, already importing the necessary packages, such as javax.servlet.http.*.
If you are using a Eclipse with a Maven plugin installed then, after configured it, you can only add the following dependencies:
http://mvnrepository.com/artifact/javax.servlet/servlet-api/2.5
http://mvnrepository.com/artifact/javax.servlet/jstl/1.2
http://mvnrepository.com/artifact/javax.servlet/jsp-api/2.0
In fact, you can see this tutorial explaining very well all the steps to create a Dynamic Web Prroject using WTP.
Or by ugin Maven, this one and this full explained.
Hope this help...

Related

Vaadin on Netbeans -- which jar?

i'm looking to use Vaadin on Netbeans 8.
I installed the Vaadin plug-in on Netbeans.
Followed the instructions on https://vaadin.com/wiki/-/wiki/Main/Getting+Started+on+NetBeans.
The jar i'm using is vaadin-all-7.3.8.
I assigned Tomcat to the project.
However - com.vaadin isn't recognized for all what it has in the environment-- com.vaadin.ui and com.vaadin.Application aren't seen.
I'm getting checked errors to
import com.vaadin.Application;
and
import com.vaadin.ui.*;
, but not to
import com.vaadin.*;
What more do i need for Vaadin on Netbeans??
TIA.
//=======================
EDIT:
Pls note: Saw Using Vaadin on NetBeans WITHOUT Maven along with some other discussions.
Also note: We're looking to avoid Vaadin-on-Maven. have already had issues with that one as well.
Be sure to read the readme in the zip file that tells you which jar files you need to include in your project:
Copy all vaadin-* files except vaadin-client and vaadin-client-compiler to WEB-INF/lib in your project
Copy lib/*.jar to WEB-INF/lib in your project
Copy vaadin-client and vaadin-client-compiler to a lib folder which is on your classpath but will not be deployed. These files are only needed when compiling a module (widget set) to Javascript.
What issues did you have with maven? Typically I would recommend using a dependency management tool to make upgrades easier in the future.

Creating new servlet in eclipse kepler for maven web app project

I created simple maven web application project. After creation there were no 'src/main/java' and 'src/test/java' folders but only 'src/main/resources'.
I added this two folders and updated maven project.
Than I added some package to 'src/main/java' and try to add servlet by right click at package element
At next step I see window with some servlet details
But when I start to add servlet name eclipse shows me message that "Not a java source folder".
By the same way I can add simple class to this pachage without any problem but in case of servlet I cannot. Do I miss something during configuration?
I could not find the cause of the problem, but I solved it restarting Eclipse (I have Eclipse Neon.2 Release (4.6.2)).

Importing existing JSP project to Eclipse or Net Beans

I am trying to import project from some server on my localhost.
I would prefer to import it in NetBeans, but Eclipse is also fine. I set up Tomcat server in NetBeans for now. Then I tried to create new Java Web project with existing source and then I go through the wizard, and when I should select Web pages folder, Web-inf content it says: "Web Pages folder overlaps Project folder."
But I am not sure what kind of setup should I have there. If you maybe have some advice or video tutorial, that would be awesome..
Thanks!
you can directly import it through eclipse , there is a option of importing some project , don't create a new project

Hibernate Setup in eclipse helios

How I can setup Hibernate for a Dynamic Web application by using Eclipse Helios? I am a newbe so please let me know if there is any example.
I tried for Java application and included all JARS and it worked fine. But don't understand how I can do it for Web application and test it.
I will use Struts2 so I will appreciate if I can get appropriate example or guidance.
Drop the jars in WEB-INF/lib. Those jars are automatically added by Eclipse to the project build path, and constitute (with the WEB-INF/classes directory and the container classpath) the classpath of the webapp.
http://hardik4u.wordpress.com/2008/09/02/struts-2-hibernate-3-integrationcomplete-using-eclipse/
https://stackoverflow.com/questions/4364923/struts2-and-hibernate-framework-create-in-eclipse
First, download Struts2, and import example WAR file into Eclipse. You can find it from the source folder: struts-2.3.1-all\struts-2.3.1\apps\struts2-blank.war
Second, you should install Eclipse Hibernate Plugin. Goto Window > Preferences > Install/Update > Available Software Sites and add following link and name it JBossTools or something.
http://download.jboss.org/jbosstools/updates/helios/
Depending on your needs you can install Hibernate Plugins for many project types. In this case, select web application plugin.
And after, you should include Hibernate Core libraries into your classpath. I would recomment Hibernate 3.6 and greater. Because it does not depend on asm (asm-3.3.jar, asm-commons-3.3.jar ...) anymore. If you use earlier versions you might encounter some problems, since Struts2 also depend on asm libraries.
Then create your database, and use following link to configure and generate model bean classes.
http://casteyo.wordpress.com/2007/06/06/conf_hibernate/
Now you don't need to write mapping files by yourselves. And with DAO factory pattern you have your way to finish your project.
Hope this helps, and Goodluck

Importing a existing Web Application , into Eclipse

I need to import a existing Web Application , into Eclipse .
Please see the Structure of my Web Application as shown in the below figure .
http://imageshack.us/f/220/structurek.jpg/
From Eclipse IDE , while using import What option i need to select that is should i use
Existing projects into Eclipse
Archive File
File System
please see this image
http://imageshack.us/f/850/eclipseo.jpg/
Import existing projects into Eclipse works only for projects that were created in Eclipse.
And you're definitely not dealing with an Archive File here.
Import from the File System just copies the resources but does not actually create an Eclipse project for you.
What I would advise you, is to create a new Dynamic Web Project, configuring all the required facets, and then just copy all the contents of your existing app to the WebContent folder, either by drag'n'dropping it into the Project Explorer or by using Import from the File System, overwriting all the contents.
So far, there seems to be no other way to do it in Eclipse. However you may check out the similar post. The user #RC recommends using ant task for this process, but I'm more than sure that it won't configure all the required facets for you. It may work for some simple Java projects, but surely not enough for Java EE projects.