Different components needed to build Java Web App - Beginner Question

Discussion in 'Java' started by Agapito, Aug 3, 2007.

  1. Agapito

    Agapito Guest

    Dear All

    I am doing research on the best components to use for building a Web Java
    Application that is using a database backend.

    So far, this is what I have understood:

    1. All my pages will be in JSP. User will enter his choices and the form
    button (submit) will invoke related servlet.

    2. I should use servlet to connect to database and get results and generate
    a JSP with dynamic content.

    3. To enable activity of different user interface components (buttons,
    textbox, listbox, etc) I should use either Java Server Faces or Struts.

    4. For server, I plan to use Sun Application Server PE 9.


    I will be deeply grateful for help and clarification, to help me use the
    best choices available:

    Question 1: Is my understanding correct ? Or there are better ways to go
    about building the site?

    Question 2: except coding html directly into code of a servlet to generate
    JSP, are there any other or better ways to do so?

    Question 3: Many advise using Java Server Faces instead of Struts, claiming
    that it includes all Struts functionality and more ... is this the case ?



    Most appreciate your help ....
    Agapito
    Agapito, Aug 3, 2007
    #1
    1. Advertising

  2. Agapito

    Amit Jain Guest

    Before starting any web application you must need to understand
    MVC(Model View Controller), so I would like to suggest one book
    "Servlet & JSP Head First". This book explain everything.


    Thanks
    Amit Jain, Aug 3, 2007
    #2
    1. Advertising

  3. Agapito

    Amit Jain Guest

    Question 2: except coding html directly into code of a servlet to
    generate
    JSP, are there any other or better ways to do so?

    Your question is little confusing, servlet never generate JSP remember
    JSP code is translated into servlet which is stored in the work
    directory of Tomcat.

    First go through Life Cycle of Servlet and JSP things get clear to
    you.
    go through "Head First" first.


    Thanks...
    Amit Jain, Aug 3, 2007
    #3
  4. Agapito

    Amit Jain Guest

    Amit Jain, Aug 3, 2007
    #4
  5. Agapito

    Agapito Guest

    >Question 2: except coding html directly into code of a servlet to
    >generate JSP, are there any other or better ways to do so?


    > Your question is little confusing, servlet never generate JSP remember
    > JSP code is translated into servlet which is stored in the work
    > directory of Tomcat.
    >
    > First go through Life Cycle of Servlet and JSP things get clear to
    > you.
    > go through "Head First" first.


    First of all thank you very much for your reply ....
    What I meant by my question is , in a servlet , we usually code something
    like this:

    out.println("<html>");
    out.println("<head>");
    // some code
    out.println("</head>");
    out.println("<body>");
    //some code
    out.println("</body>");
    out.println("</html>");

    I could have a page with some frames or images and it could take time if I
    want to code everything through HTML (worse if I change something - I will
    have to change code in all servlet codes !) , so I wonder if there is a way
    to do this in a different way ?

    Agapito
    Agapito, Aug 3, 2007
    #5
  6. Agapito

    milesd Guest

    On 03/08/2007 15:07:29, "Agapito" wrote:
    >>Question 2: except coding html directly into code of a servlet to
    >>generate JSP, are there any other or better ways to do so?

    >
    >> Your question is little confusing, servlet never generate JSP remember
    >> JSP code is translated into servlet which is stored in the work
    >> directory of Tomcat.
    >>
    >> First go through Life Cycle of Servlet and JSP things get clear to
    >> you.
    >> go through "Head First" first.

    >
    > First of all thank you very much for your reply ....
    > What I meant by my question is , in a servlet , we usually code something
    > like this:
    >
    > out.println("<html>");
    > out.println("<head>");
    > // some code
    > out.println("</head>");
    > out.println("<body>");
    > //some code
    > out.println("</body>");
    > out.println("</html>");
    >
    > I could have a page with some frames or images and it could take time if I
    > want to code everything through HTML (worse if I change something - I will
    > have to change code in all servlet codes !) , so I wonder if there is a
    > way to do this in a different way ?
    >
    > Agapito
    >
    >



    You need something to serve the webpages. This will be something like the
    apache webserver.

    Something to parse/process the Java - Java Application Server.

    The best thing to do is take a look at Getting Started with Web Applications
    - starting with Servlets, JSP, and JSF.

    http://java.sun.com/j2ee/1.4/docs/tutorial/doc/About.html

    and

    http://java.sun.com/j2ee/1.4/docs/tutorial/doc/Overview2.html

    and

    http://java.sun.com/j2ee/1.4/docs/tutorial/doc/Overview3.html

    These describe what is needed to build a Java Web Application.


    Miles.
    milesd, Aug 3, 2007
    #6
  7. Agapito

    david.karr Guest

    On Aug 3, 5:47 am, Amit Jain <> wrote:
    > Question 3: Many advise using Java Server Faces instead of Struts,
    > claiming
    > that it includes all Struts functionality and more ... is this the
    > case ?
    >
    > http://websphere.sys-con.com/read/46516.htm


    Note that this article is almost 3 years old. Many things have
    changed since then.
    david.karr, Aug 3, 2007
    #7
  8. Agapito

    Lew Guest

    Re: Different components needed to build Java Web App - BeginnerQuestion

    "Agapito" wrote:
    >> What I meant by my question is , in a servlet , we usually code something
    >> like this:
    >>
    >> out.println("<html>");
    >> out.println("<head>");
    >> // some code
    >> out.println("</head>");
    >> out.println("<body>");
    >> //some code
    >> out.println("</body>");
    >> out.println("</html>");
    >>
    >> I could have a page with some frames or images and it could take time if I
    >> want to code everything through HTML (worse if I change something - I will
    >> have to change code in all servlet codes !) , so I wonder if there is a
    >> way to do this in a different way ?


    Yes, it's called "JSP" or "Java Server Pages". We almost never code something
    like what you showed as a servlet; it's very bad practice, actually. We code
    layout in JSPs, and navigation and controller logic in servlets (along with a
    few special functions).

    So your example would be more like:

    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>The Right Way To Do JEE Web Apps - A Separate View</title>
    </head>
    <body>
    <img src="images/some.png" />
    <h1>The Right Way To Do JEE Web Apps - A Separate View</h1>
    <div>
    <%-- some text and markup and some dynamic content --%>
    </div>
    </body>
    </html>

    --
    Lew
    Lew, Aug 3, 2007
    #8
  9. Re: Different components needed to build Java Web App - BeginnerQuestion

    Agapito wrote:
    > Dear All
    >
    > I am doing research on the best components to use for building a Web Java
    > Application that is using a database backend.
    >
    > So far, this is what I have understood:
    >
    > 1. All my pages will be in JSP. User will enter his choices and the form
    > button (submit) will invoke related servlet.
    >
    > 2. I should use servlet to connect to database and get results and generate
    > a JSP with dynamic content.
    >
    > 3. To enable activity of different user interface components (buttons,
    > textbox, listbox, etc) I should use either Java Server Faces or Struts.
    >
    > 4. For server, I plan to use Sun Application Server PE 9.
    >
    >
    > I will be deeply grateful for help and clarification, to help me use the
    > best choices available:
    >
    > Question 1: Is my understanding correct ? Or there are better ways to go
    > about building the site?
    >
    > Question 2: except coding html directly into code of a servlet to generate
    > JSP, are there any other or better ways to do so?
    >
    > Question 3: Many advise using Java Server Faces instead of Struts, claiming
    > that it includes all Struts functionality and more ... is this the case ?


    It sounds OK.

    But be aware that you will need to learn a lot !!

    I would recommend JSF over Struts.

    And I would recommend JBoss (or maybe Geronimo) over
    SUN Application Server.

    Arne
    =?ISO-8859-1?Q?Arne_Vajh=F8j?=, Aug 4, 2007
    #9
  10. Agapito

    Lew Guest

    Re: Different components needed to build Java Web App - BeginnerQuestion

    Arne Vajhøj wrote:
    > I would recommend JSF over Struts.


    While the article cited upthread that compares the two is perhaps a bit old,
    its points are still valid. JSF is a way more flexible framework, although
    sometimes I miss the comforting autocracy of Struts. It also seems to support
    more than one style of web-app development. I've been learning JSF recently.
    The basics are quick enough to pick up, but there are subtleties and
    opportunities galore.

    > And I would recommend JBoss (or maybe Geronimo) over
    > SUN Application Server.


    The Sun App Server these days is precisely the open-source Glassfish JEE
    server, but with a different installer. I've only played with Glassfish a
    tiny bit, and JBoss not at all. What do you see as the relative advantages?

    --
    Lew
    Lew, Aug 4, 2007
    #10
  11. Agapito

    David Segall Guest

    "Agapito" <> wrote:

    >Dear All
    >
    >I am doing research on the best components to use for building a Web Java
    >Application that is using a database backend.

    If you have some Java experience start here
    <http://developers.sun.com/jscreator>. JSF is _much_ easier to learn
    than Struts. Make sure you know some Java before you attempt the
    intimidating combination of Java, HTML, and client/server programming.
    David Segall, Aug 4, 2007
    #11
  12. Agapito

    Agapito Guest

    I would like to thank you all for your help and replies :)
    Agapito, Aug 8, 2007
    #12
  13. Re: Different components needed to build Java Web App - BeginnerQuestion

    Lew wrote:
    > Arne Vajhøj wrote:
    >> I would recommend JSF over Struts.

    >
    > While the article cited upthread that compares the two is perhaps a bit
    > old, its points are still valid. JSF is a way more flexible framework,
    > although sometimes I miss the comforting autocracy of Struts. It also
    > seems to support more than one style of web-app development. I've been
    > learning JSF recently. The basics are quick enough to pick up, but
    > there are subtleties and opportunities galore.


    Additionally JSF fits better with portals and there are a lot more
    AJAX stuff available for JSF.

    >> And I would recommend JBoss (or maybe Geronimo) over
    >> SUN Application Server.

    >
    > The Sun App Server these days is precisely the open-source Glassfish JEE
    > server, but with a different installer. I've only played with Glassfish
    > a tiny bit, and JBoss not at all. What do you see as the relative
    > advantages?


    The main reason is CV benefits not technical.

    There are much better chance to have to work with JBoss or
    Geronomi (or one of its commercial offsprings) than with
    Glassfish/SUN.

    Arne
    =?UTF-8?B?QXJuZSBWYWpow7hq?=, Aug 12, 2007
    #13
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brad Smallridge
    Replies:
    5
    Views:
    1,162
    Mike Treseler
    Oct 12, 2004
  2. Dave Diehl
    Replies:
    4
    Views:
    784
    Dave Diehl
    Aug 11, 2004
  3. Rico
    Replies:
    0
    Views:
    399
  4. Mickey Segal
    Replies:
    0
    Views:
    855
    Mickey Segal
    Feb 2, 2004
  5. Rico
    Replies:
    1
    Views:
    287
Loading...

Share This Page