Solved

Advice on good JSP practices to adopt

Posted on 2006-06-18
15
468 Views
Last Modified: 2010-04-01
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
0
Comment
Question by:dfu23
  • 6
  • 5
  • 2
  • +2
15 Comments
 
LVL 3

Assisted Solution

by:runa_paathak
runa_paathak earned 100 total points
ID: 16932087
Tapestry (http://jakarta.apache.org/tapestry/) is a popular framework, you can check that out.
0
 
LVL 16

Assisted Solution

by:suprapto45
suprapto45 earned 100 total points
ID: 16932316
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
 
LVL 15

Accepted Solution

by:
bpmurray earned 250 total points
ID: 16932985
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
 
LVL 14

Author Comment

by:dfu23
ID: 16938329
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
 
LVL 16

Expert Comment

by:suprapto45
ID: 16940393
>>"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
 
LVL 4

Assisted Solution

by:evnafets
evnafets earned 50 total points
ID: 16946895
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
 
LVL 14

Author Comment

by:dfu23
ID: 16947811
Any good/recommended links on JSTL?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 15

Expert Comment

by:bpmurray
ID: 16950276
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
 
LVL 14

Author Comment

by:dfu23
ID: 16954092
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
 
LVL 15

Expert Comment

by:bpmurray
ID: 16954179
Yes - JSF is a little like the J2EE ASP.net. Also search around for Facelets.
0
 
LVL 14

Author Comment

by:dfu23
ID: 16964632
Ah ... another thought ...

Can anybody tell me about Bouncey Castle?
0
 
LVL 15

Expert Comment

by:bpmurray
ID: 16967548
It's  a fun way to dislocate your kid's elbow?
0
 
LVL 14

Author Comment

by:dfu23
ID: 16996726
Ok ... that's cool,

One last thing ... can anybody tell me anything about Hibernate? Is that a framework? What does it give you?
0
 
LVL 15

Expert Comment

by:bpmurray
ID: 16997215
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
 
LVL 14

Author Comment

by:dfu23
ID: 17017620
Thanks to all for their inputs ...
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

In this article, I will show you HOW TO: Suppress Configuration Issues and Warnings Alert displayed in Summary status for ESXi 6.5 after enabling SSH or ESXi Shell.
Moving applications to the cloud or switching services to cloud-based ones, is a stressful job.  Here's how you can make it easier.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now