Different components needed to build Java Web App - Beginner Question

A

Agapito

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
 
A

Amit Jain

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
 
A

Amit Jain

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

Agapito

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
 
M

milesd

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

Lew

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

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

Agapito said:
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
 
L

Lew

Arne said:
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?
 
D

David Segall

Agapito said:
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.
 
G

Guest

Lew said:
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.
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top