Advice on good JSP practices to adopt

Experts,

I am about to take over the design and development of a JSP project that, as of right now, I don't have many details on. That's the bad part ... the good part is that I should have rather good flexibility on changing or possibly even re-writing the entire project. Before I do that though ... I think that it would be best for me to ask some Java folks for their recommendataions on best practices and any lessons learned.

For a quick background on my web dev history I am primarily ASP and ASP.NET but I have done a bit of Java and JSP so I am not completely foreign to the environment. Please toss in my direction any decent frameworks or other good resources that I should look into adopting into my development efforts.

A huge thank you in advance to all those that have feedback,

Wally Atkins
LVL 14
dfu23Asked:
Who is Participating?
 
bpmurrayConnect With a Mentor Commented:
There are a number of things you need to take into account. One of these is the tooling: is the app going to be developed using something simple like notepad or vi, or one of the full-featured dev environments like Rational Application Developer or JDeveloper? If the former, then it should be based on a reasonably simple framework; if the latter, you can use more advanced frameworks, such as JavaServer Faces, Tapestry or Struts. While Tapestry is every bit as good as JSF, it's not part of J2EE, so that's why I'd go the JSF route. Similaraly Struts has a great controller but mediocre UI features and is not part of J2EE.

As for the actual JSPs themselves, I'd recommend that embedded Java code be kept to a minimum. You can hide a lot of this in tags if necessary, or in server-side beans or similar. The reason for this is that maintenance can be done using the web folk, rather than the Java folk, and you'll also find that this helps with reuse: much of the Java code is repeated in many pages, so it makes sense to factor it out into

Another thing I very strongly advocate is that you slavishly follow the recommendations of W3C and other standards bodies: avoid anything proprietary if you can. Try to make your site at least XHTML 1.0 compatible, and create a strong separation between the styling (CSS) and the app. In fact, follow the WSRP 2.0 styling guidelines so that your app will be at least somewhat future-proofed.

Oh - one other thing: avoid rewriting. While on the face of it, this may appear to be the best solution, the existing app has fixes for all the unsavoury events that have occurred in its history. You really and truly do not want to lose that! To understand this, read Joel's article ("old" now, but still relevant): http://www.joelonsoftware.com/articles/fog0000000069.html
0
 
runa_paathakConnect With a Mentor Commented:
Tapestry (http://jakarta.apache.org/tapestry/) is a popular framework, you can check that out.
0
 
suprapto45Connect With a Mentor Commented:
Hi,

For me, I would go for Struts. However, Tapestry as suggested by runa_paathak is also a good framework. To learn these two frameworks, you need time to learn it so it would be ideal for you to allocate some times to research these frameworks.

But the most important thing of these frameworks are you need to separate your application into layers such as presentation layer (user interface), control layer (business logic) and back-end (database). I believe that ASP.NET would have similar things especially if you have experiences in C#.

David
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
dfu23Author Commented:
Ok,

I am familiar with the CSLA framework by Rockford Lhotka (http://www.lhotka.net/) which is a layered framework for .NET and it appears that some of the principles would be similar across the board. Can anyone give me a quick run down on pros and cons with some of these frameworks (or links to such things):

 - Struts
 - Tapestry

Also, any input about using these frameworks inside of an IDE like Eclipse or another free type of development program would be beneficial.

bpmurray, I completely agree about the use of W3C recommendations and will utilize as much as allowed by my contstraints and as it logically makes sense. However, you mentioned WSRP 2.0 which is an acronym that I am unfamiliar with ... could you elaborate?

Thanks,

Wally
0
 
suprapto45Commented:
>>"Can anyone give me a quick run down on pros and cons with some of these frameworks "
I can't say much on here as I have no experienced on Tapestry but as far as I know, Tapestry is the newer technology compared to Struts. It may or may not replace Struts in the future. Additionally, there are many other frameworks that gain popularity such as Spring and etc. So it would be hard to predict. One thing that I know is that Struts has been spread widely and used anywhere and this is the point where it is hard to be replaced - popularity.

>>"any input about using these frameworks inside of an IDE like Eclipse"
Yes, I believe that Eclipse has so many open-source plugin for Struts. You can go ahead to google it. But for me, I normally do it manually in Eclipse :).

David
0
 
evnafetsConnect With a Mentor Commented:
I would second the recommendation of keeping embedded java code to a minimum.
In fact, I would go so far as to say keep the JSP pages completely scriptlet free.  It is quite possible, and saves maintenance headaches at a later date.

For custom tags, check out JSTL  (JSP Standard Tag Library).  It provides almost everything you need to eliminate scriptlet code from JSPs.  
0
 
dfu23Author Commented:
Any good/recommended links on JSTL?
0
 
bpmurrayCommented:
Well, JSTL came from Apache (search jakarta.apache.org) and has been included in the latest versions of J2EE. Here's the stuff from the horses mouth: http://java.sun.com/products/jsp/jstl/ - some of this is difficult to chew through, so I'd try one of the tutorials - here's one from one of my favourite tech sites: http://www-128.ibm.com/developerworks/java/library/j-jstl0211.html

Otherwise, just google for JSTL or visit your local bookshop.

0
 
dfu23Author Commented:
Just curios,

Is there anything in Java/JSP that has something towards the equivalent of ASP.NET web controls? Like:

<asp:label>
<asp:button>
<asp:dropdownlist>
0
 
bpmurrayCommented:
Yes - JSF is a little like the J2EE ASP.net. Also search around for Facelets.
0
 
dfu23Author Commented:
Ah ... another thought ...

Can anybody tell me about Bouncey Castle?
0
 
bpmurrayCommented:
It's  a fun way to dislocate your kid's elbow?
0
 
dfu23Author Commented:
Ok ... that's cool,

One last thing ... can anybody tell me anything about Hibernate? Is that a framework? What does it give you?
0
 
bpmurrayCommented:
Hibernate is a pretty good way of providing a mechanism to encapsulate data access in Plain Old Java Objects (POJOs). It's often used in conjunction with Spring and/or iBatis.

There's a whole load of these things that work very well indeed together. There's a very good book called "POJOs in Action" by Chris Richardson that explains these very well, with good examples.
0
 
dfu23Author Commented:
Thanks to all for their inputs ...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.