>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:

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 ?

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.

"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).

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.

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?

"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.

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.

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!