Re: JSP Web-Development [newbie]
On 28-07-2010 14:37, Chris Riesbeck wrote:
On 7/28/2010 12:31 PM, pmz wrote:
Dear Group,
1. At the beginning I'd like to apologize you for any mistakes or
misunderstood's, which might occur in message below, but I'm a quite
beginner in JSP so maybe some of my problems aren't really problems ;)
My Java knowledge is intermediate, but the structures of JSP or JSF or
any other frameworks is pretty bad, but I do not have any idea how to
start.
Personally, I prefer JSTL over straight JSP, to reduce jumping back and
forth between HTML and Java syntax. So iteration over a collection is
<ul>
<c:forEach var="item" items="${myObj.thingies}">
<li><c:out value="${item}" /></li>
</c:forEach>
</ul>
instead of
<ul>
<% for (Object item : myObj.getThingies()) { %>
<li><%= item %></li>
<% } <%>
</ul>
Very good advice.
With newer versions:
<li><c:out value="${item}" /></li>
can even be written as:
<li>${item}</li>
2. I'm trying to build bit complex website based on JSP (which I've
done a lot in PHP, so the main idea of website engineering is quite
common for me), but I a bit confused about the architecture/structure
of a JSP webpage building. The problem is, I'm not able to imagine in
my mind, how the architecture (directory structure) should be found,
how do I divide the template files, the engine core, etc.
You can do almost anything, but don't put pages and other user-viewable
items under WEB-INF. WEB-INF is for libraries, class files, and XML
configuration files. So you could have
webapp/
pages/
jsp files
styles/
css files
images/
...
WEB-INF/
classes/
...
...
and other flatter or more nested structures as you choose.
JSP pages in WEB-INF are not directly accessible, but they can
be used from servlet / action classes.
Some even consider that good practice.
I don't agree, but ...
Arne