Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Eclipse web.xml servlet mapping?

 
nick tomer
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am working with eclipse and i made a HelloWorld servlet and it run properly.
I know that when you make a servlet you must configure a web.xml file to map the servlet to a url but
i was searching to find the web.xml in eclipse that maps the servlet url but nothing. Where is it?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64683
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be sure to ask IDE questions in the IDEs forum. I have moved this post there for you.
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For my web apps, the file is always located at src/main/webapp/WEB-INF/web.xml, but then I use m2eclipse to create my projects. What are you using to create your web app projects?
 
nick tomer
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry but i don't understand what m2eclipse is?
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://m2eclipse.sonatype.org/
 
nick tomer
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I AM NOT USING ANYTHING EXTRA. I JUST INSTALLED THE ECLIPSE 6.9 AND TOMCAT 7 AND STARTED WORKING.
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nick tomer wrote:I AM NOT USING ANYTHING EXTRA. I JUST INSTALLED THE ECLIPSE 6.9 AND TOMCAT 7 AND STARTED WORKING.


Please do not post in all caps. It's equivalent to shouting and is considered rude.
 
nick tomer
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i didn't knew that. sorry
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i was searching to find the web.xml in eclipse that maps the servlet url but nothing. Where is it?


"Ctrl + Shift + R" in Eclipse will open a window where you can type the resource you are searching for (web.xml in this case).
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nick tomer wrote:I AM NOT USING ANYTHING EXTRA. I JUST INSTALLED THE ECLIPSE 6.9 AND TOMCAT 7 AND STARTED WORKING.

Eclipse 6.9?
AFAIK, Eclipse now at version 3.6 .
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I may be wrong but I think web.xml isn't required for JEE 6 (Tomcat 7 implements JEE 6) and maybe that is why he can't locate web.xml.
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John Todd wrote:I may be wrong but I think web.xml isn't required for JEE 6 (Tomcat 7 implements JEE 6) and maybe that is way he can't locate web.xml.


That's a good point. web.xml is indeed optional in Java EE 6. So it actually boils down to what URL nick used to test his application and which servlet (if any) got invoked.

 
Tim Holloway
Saloon Keeper
Pie
Posts: 18094
48
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no "web.xml in Eclipse". The web.xml file is in the J2EE WAR in the WEB-INF directory. Yes, JEE allows it to be be omitted or minimized in a lot of cases, but Eclipse has no inherent J2EE/JEE capabilities to begin with (they're supplied via Eclipse pug-ins), and in any event, a compliant J2EE/JEE app cannot be dependent on an IDE. Just because you develop it using an IDE and test it using an IDE, doesn't mean that the actual webapp is allowed to omit critical WAR elements when the spec demands them.
 
nick tomer
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks a lot.

p.s. indeed, eclipse version is 3.6. i mixed up with netbeans.
 
Marcelo Yamashita
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For some reason I got the same problem here.
I dont have any web.xml file in an EJB project that has a websercive running.

Its actually a problem, because every tutorial for securing web services strives for changes in the web.xml file. And i dont have one.

I know that this is kind of 'other post', but ..

.. how can I secure a webservice (authentication/authorization) without a web.xml file?


[] in advance.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18094
48
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Marcelo!

This isn't quite the same topic as the original question, so it would have been better to start a new thread. But, since we've raised it from the dead, might as well continue!

JEE (not J2EE) allows the concept of "not having web.xml". Like JSF2, it does this by allowing the default definitions for values to be declared as annotations to the java source code.

Without actually reading the manual I seem to recall that there's an annotation that can allow you to put security controls on certain web resources via annotations, but I don't think that the master controls can be done that way. By "master controls", I mean global things like security transport mechanism selected, whether to use BASIC or form-based authentication and role name definitions. So you probably still need a minimal web.xml file to contain those things.

In J2EE, web.xml is mandatory, since the annotation support didn't exist back then. Note that for legacy EJBs, however, the EJBs had their own config files as well.
 
Nani Marni
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will get web.xml file by creating project like this in eclipse:-
File->New->Dynamic Web Project->Next->Next->Generate web.xml deployment descriptor(Select this check box)
then you will find the web.xml file under WebContent/WEB-INF
 
shaileshkumar mistry
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi nick


you might be using annotations. if you are using annotations to map the url the entry wont be there in web.xml
Please check on top of servlet. you are finding syntax like

@WebServlet("/yourservlet");
 
Brandon Ke
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nick tomer wrote:Hi, I am working with eclipse and i made a HelloWorld servlet and it run properly.
I know that when you make a servlet you must configure a web.xml file to map the servlet to a url but
i was searching to find the web.xml in eclipse that maps the servlet url but nothing. Where is it?


So I realize I am just shy of 3 years late to this party but in the event that anyone else stumbles upon this thread and needs a solution:

I am using Eclipse for JEE Developers (Helios) and deploying to a remote Glassfish Server running on a Linux box. The web.xml file will appear in the management console of the Glassfish server under the deployed .war program, but by default it doesn't show up in your Eclipse project's hierarchy. To generate this in Eclipse try this: Right-Click on your project -> go to 'Java EE Tools' -> and select 'Generate Deployment Descriptor Stub'. At this point you should see the "web.xml" file appear inside your "WebContent/WEB-INF/ " directory. Hope this helps.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic