some question about JSP from a beginner, plz help!

hi experts, i have just install tomcat5 and thinking of start learning JSP. however, i notice that none of the reference book, tutorials i got mention about the /WEB-INF/web.xml in detail, like how to create/ configure it... what is this and that inside it... oh ya, most importantly, what it is?
so my questions:
1. what is /WEB-INF/web.xml? what is it used for? how can i create/configure it?
2. i was told that servlet and jsp are two different things, but when i read thru my jsp tutorial, the servlet keep coming up, what is the relationship between them?
3. again, i was told that i dun really need tomcat to run my jsp app, instead, i can use J2EE, is that correct? if yes, which is better?
4. any suggestion where/how should i start learning and those elements that i need to pay attention to when learning/writing JSP apps.

take note that i am a complete beginner in web language, and those info in the spec&doc of tomcat, j2ee, jsp, servlet really confuse me. beside making my head few times bigger, i guess they help me little in learning JSP. so i would appreciate the comments will be made in simple form (and understandable by idiot like me!).

tks
zeBesAsked:
Who is Participating?
 
suprapto45Connect With a Mentor Commented:
Hi,

I sent you this URL in the first message.
>>"Sun (just download the pdf)
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/"

I think that the way to configure your web.xml is in that tutorial in the servlet chapter.

Regards
Dave
0
 
suprapto45Commented:
Hi,

First is that you need to know what is the difference between JSP and Servlet. Think this way....JSP is the HTMP page that will interact with your clients. Servlet is actually your java class that will get the information from your JSP (information from clients) and do all the business logics for it and do something else. So, conclusively, the flow would be JSP - Servlet - DB. Do you get what I mean?

Then your web.xml is actually deployment descriptor. It helps you to map your Servlet (Listener, Filter) and etc. So, to make your Servlet accessible from the JSP, you need to set the path of the Servlet in your web.xml. Otherwise, your Servlet will be useless :).

Thus, my web.xml look like below.

web.xml
----------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
                         "http://java.sun.com/dtd/web-app_2_3.dtd">
<!-- Copyright (c) 2002 by ObjectLearn. All Rights Reserved. -->
<web-app>
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
    <error-page>
        <error-code>404</error-code>
        <location>/error.jsp</location>
    </error-page>  
     
    <servlet>
        <servlet-name>RedirectLogOut</servlet-name>
        <servlet-class>com.yourpackage.RedirectLogOut</servlet-class>
    </servlet>      
       
    <servlet-mapping>
        <servlet-name>RedirectLogOut</servlet-name>
        <url-pattern>/RedirectLogOut</url-pattern>
    </servlet-mapping>        
 
</web-app>


Well, you can use J2EE server from Sun but I recommend you to use the famous server such as Tomcat, IBM WSAD, Bea WebLogic, Orion, Resin or etc. The reason is that most of the big companies are using these servers so you should use them.  

To learn all these J2EE jargons, you really need to know few things i.e. JSP, Servlet. That's all for the beginners. Then afterward, you can start to touch the advance jargons of J2EE such as Struts, Hibernate and etc. Let me give you some URL for you to learn.

Sun (just download the pdf)
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/

Servlet - Sun
http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/Servlets.html

Resin Server (though server but it should be similar to Tomcat :))
http://www.caucho.com/resin-3.0/servlet/tutorial/helloworld/index.xtp

Regards
Dave
0
 
suprapto45Commented:
Hi,

Forgot one thing. Well, to configure your web.xml, you can modify it manually or you can use third party tools such as Eclipse, NetBeans or etc.

Oh yes, I want to recommend you to use Eclipse as the IDE. www.eclipse.org
It has many wizards that can help you to make your J2EE programming faster :).

Regards
Dave
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
zeBesAuthor Commented:
hmm, now it become clearer to me bout the jsp-servlet relationship..
but regarding the web.xml, do u have any reference/ tutorial of how to configure it manually?
and, i forget to ask this question: what is ant? all i know is it's a tool to do sth.. haha
0
 
zeBesAuthor Commented:
i have actually reading the tomcat 5 doc and start learning how to use it. and it provides a base web.xml, but the problem is i do not know how to configure it..

0
 
suprapto45Commented:
Hi,

You should not change the Tomcat web.xml. The one that you should change is your web application's web.xml. It is normally located in your WEB-INF folder. Conclusively, you have two web.xml. One is in the Tomcat's context and another one is on your web application context. If you want to map your servlet, you should map it in your web application context.

Ant is actually a Java-based build tool. Have you ever heard about the "make" in C++? So by using this Ant, you can compile and deploy your web application easily. Normally, for Java app, if you want to compile and test, you need to type a lot of commands in console, it is tedious. So by using Ant, you can compile and test your application in single click :).

Maybe this URL may help you.

http://www.onjava.com/pub/a/onjava/2001/04/19/tomcat.html

Regards
Dave
0
 
zeBesAuthor Commented:
back to the WEB-INF/web.xml question again, any tutorial on how to configure it? or is it included in the docs of the links u provide?
0
 
suprapto45Commented:
yes,

it is in the link that I gave. Try to read on it as I am looking for additional links :).

Regards
Dave
0
 
zeBesAuthor Commented:
help me with this question as well... actually i wanted to post it here but i reckon i asked too many question...

http://www.experts-exchange.com/Web/Web_Languages/JSP/Q_21414816.html
0
 
zeBesAuthor Commented:
so i guess J2EE tutorial is where i should start...
tks!
0
 
suprapto45Commented:
Yep

:). Remember, learn JSP - Servlet first. ignore all the MVC, Struts, Hibernate and etc.

Regards
Dave
0
 
zeBesAuthor Commented:
tks for your help, Dave! i really appreciate that..
i believe i will have more questions to ask in near future, but my points is running out.. i do really hope EE give me some points for free... ;)

0
All Courses

From novice to tech pro — start learning today.