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?
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?
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.
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.
Customer surveys are for companies who didn't pay proper attention to begin with.
nick tomer
Greenhorn
Joined: Oct 18, 2010
Posts: 22
posted
0
thanks a lot.
p.s. indeed, eclipse version is 3.6. i mixed up with netbeans.
Marcelo Yamashita
Greenhorn
Joined: Feb 08, 2006
Posts: 2
posted
0
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?
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
Joined: Aug 20, 2012
Posts: 1
posted
0
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
Joined: Dec 19, 2011
Posts: 19
posted
0
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");
Thanks and Regards
OCPJP 100%
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.