Categories

Main
Database
Java
Microsoft.NET
Adabas
DB2
Informix
Microsoft SQL Server
MySQL
Oracle
Pervasive.SQL
PostgreSQL
Sybase
Other
ASP
ColdFusion
Crystal Reports
Delphi, C etc
JAVA
Microsoft.NET
Perl and the DBI
PHP
ANSI SQL
Unix Shell Scripts
Visual Basic
XML & XSLT
Corel Paradox
FileMaker
Microsoft Access
Microsoft Excel
Other PC Databases
Applications & Tools
Database Concepts & Design
EJB programming & troubleshooting
EJB design
General J2EE
XML & Web services
Web tier: servlets, JSP, Web frameworks
Performance and scalability
Industry news
TSS feedback
Mobicents Contributors
Mobicents Users
JSLEE Resource Adaptor Types
Planning JavaOne 2008
Sun Tech Days
Other Java conferences
Binary Web Services and XML
Metro and JAXB
GlassFish
GlassFish Plugins
Project jMaki
GlassFish WebTier
Mural
Java Development Tools
Java WS & XML Community News
JAXP
Java SE
6uN Early Access
Java Quick Starter
Java SE Snapshots: Project Feedback
JCK Forum
Feedback and Suggestions
JDK Distros
JDK Open Source
General JSR Discussion
JCP 2.6
JXTA Community Forum
ME Interest
ME Cool Apps
ME General Help
ME Feedback & Suggestions
ME Application Developer Interest
Blu-ray Disc Java
ME Developer Days
Squawk
Mobile Developer Alliance
OpenCable
LWUIT
JavaFX Script Language Discussion
OpenJFX General Discussion
Scene Graph
General Performance Discussion
Your Java Career
NetBeans 6.0
Servlets
JSP
JSF
Portals and Portlets
EJB and Other Java EE Technologies
Distributed Java
Object Relational Mapping
JDBC
Web Services
Swing / AWT / SWT / JFace
JNLP and Web Start
Java Micro Edition
Sockets and Internet Protocols
Threads and Synchronization
Performance
Applets
I/O and Streams
Other Java APIs
Game Development
Java in General (beginner)
Java in General (intermediate)
Java in General (advanced)
Programmer Certification (SCJP)
Developer Certification (SCJD)
Associate Certification (SCJA)
Web Component Certification (SCWCD)
EJB Certification (SCBCD)
Mobile Application Certification (SCMAD)
Architect Certification (SCEA)
Web Services Certification (SCDJWS)
XML Certification
Product and Other Certifications
Mock Exam Errata
Sun Certification Results
Authors' Corral
Book Reviews
Events
Bunkhouse Porch
Teachers' Lounge
Testing
OO, Patterns, UML and Refactoring
IDEs, Version Control and other tools
Ant, Maven and Other Build Tools
Linux / UNIX
Mac OS
HTML and JavaScript
XML and Related Technologies
Agile and Other Processes
General Computing
Security
Groovy
Scala
Other Languages
Struts
Application Frameworks
Other Open Source Projects
BEA/Weblogic
IBM/Websphere
Oracle/OAS
Apache/Tomcat
JBoss
Other Java Products and Servers
JavaRanch
Cattle Drive (java college)
Moderators Only
Trash Can
Jobs Offered
Jobs Wanted
Jobs Discussion
Meaningless Drivel
Programming Diversions
Blatant Advertising
Java Announcements
New To Java
Advanced Java
Java Applets
Networking
Threads and Synchronization
Java 2D
AWT / Swing
SWT / JFace
CLDC and MIDP
CDC and Personal Profile
Sun Java Wireless Toolkit
Enterprise JavaBeans
JavaServer Pages (JSP) and JSTL
Java Servlet
JavaServer Faces
Web Frameworks
Database
XML
Lucene
NetBeans
Eclipse
IntelliJ IDEA
JCreator
Other IDEs
Java Tutorials
Java Tips
Jobs Discussion
Jobs Offered
Jobs Wanted
Professional Certification
Forum Lobby
Java Blogs
Introductions
Reviews / Advertising
Suggestions & Feedback

Resources

Java Database
Linux
Coding
Mobile
Hardware
Software Development
Software Development
iOS,OS X
iOS,OS X
ORACLE
IBM DEVELOPER
IBM DEVELOPER
MSDN
MSDN


Tags

JSP

JavaServer Pages, JSTL, EL, custom actions, etc.

JSP Coding Conventions/Best Practices


Howdy,As part of a project that I am working on I need to either find or develop coding conventions and best practices for developing JSP. So far a Google search for such has been largely unsuccessful. Are there any industry recognized coding conventions and best practices for JSP and if so, where can I find them?[ April 10, 2006: Message edited by: Linda Walters ]--------------------Javaville GazetteNon-cooperation with evil is a duty.  -- Mahatma Gandhi

   
   
   
   
   
      Modern best-practices are leaning towards scriptless JSP pages that employ the JSTL and EL, along with custom actions (tags), to replace what used to be done with scriptlets. Without any Java code on the pages, coding conventions become a simple matter of dictating how the EL should be used to reference scoped variables.--------------------[Smart Questions] [JSP FAQ] [Books by Bear]  [Bear's FrontMan] [About Bear]

   
   

 
   
      I've also read that only request attributes should be used by JSP.There's a whole chapter about JSP/JSTL usage in J2EE Design and Architecture.You might be interested in it.--------------------SCWCD Wall of Fame SCBCD Wall of FameAll roads lead to JavaRanch

   
   
   
   
   
      quote:Originally posted by Satou kurinosuke:I've also read that only request attributes should be used by JSP.Huh? I don't know where you read that but it makesnosense. Page context is an exteremly valuable location for scoped variables, especially when using the JSTL, and each of session and application scopes are essential to well-structured applications.--------------------[Smart Questions] [JSP FAQ] [Books by Bear]  [Bear's FrontMan] [About Bear]

   
   

 
   
      Sorry. I was referring to "Expert One-On-One J2Ee Design and Development".I remember that jsp views should only use the needed data from the request scope. It is not the role of views to deal with scope attributes.I read this a long time agoI'll give it another shot tonight.--------------------SCWCD Wall of Fame SCBCD Wall of FameAll roads lead to JavaRanch

   
   

 
   
      Found it, I didn't dreamIt says, p537 :"Views shouldn't be given access to session data, as they might modify it, subverting good design."Another one in the JavaBeans section:"There are four values for scope : page, request, session and application, of which only one (request) is compatible with correct use of JSP in an MVC web application, as views shouldn't access (and potentially manipulate) session or application-wide state."--------------------SCWCD Wall of Fame SCBCD Wall of FameAll roads lead to JavaRanch

   
   

   
   
      Professional JSP 2nd Editionhas chapter named Maintainability and Good Practice - read it. I can't recall the content.--------------------"My blood is tested +ve for Java."

   
   

 
   
      Here is one of the good article to start with:Best Practices to improve Performance in JSP

   
   

 
   
      Even the following site provide some good practices:http://www.javapractices.com/TableOfContents.cjp

   
   
   
   
   
      quote:Originally posted by Satou kurinosuke:Found it, I didn't dreamIt says, p537 :"Views shouldn't be given access to session data, as they might modify it, subverting good design."Another one in the JavaBeans section:"There are four values for scope : page, request, session and application, of which only one (request) is compatible with correct use of JSP in an MVC web application, as views shouldn't access (and potentially manipulate) session or application-wide state."I think that that is all complete nonsense. Just because you read something in a book doesn't always make it gospel.While I can agree that views should generally be idempotent, pretending the other scopes do not exist "because they might accidentally modify them" is patently ridiculous. One might as well say "don't write any code because you might introduce a bug".[ April 11, 2006: Message edited by: Bear Bibeault ]--------------------[Smart Questions] [JSP FAQ] [Books by Bear]  [Bear's FrontMan] [About Bear]

   
   

   
   
      I presume if you did a google search you did findJSP1.x code conventions?It would be a good place to start, even if it is a little out of date.Other things I might mention:${user.name} vs <c:out value="${user.name}"/>Even though a JSP2.0 container will recognise an EL expression on its own, still use the <c:out> tag as it escapes undesirable HTML characters.Specifying access scope of variables in EL${user} is equivalent to pageContext.findAttribute("user") which searches through the scopes page, request, session, application in that order, using the first it finds.${sessionScope.user} specifies the "user" attribute in session scope specifically.It can be argued you should always specify the scope of the attribute, both for documenting where you expect it to be, and preventing potential errors from the same attribute name being used in multiple scopes.Cheers,evnafets[ April 11, 2006: Message edited by: Stefan Evans ]

   
   

 
   
      quote:Just because you read something in a book doesn't always make it gospel.I agree. I thought I'd read that somewhere, that's all.Somebody is asking about good practices in JSP, and I 'kindly' gives himsomeinformation. It could help to have different sources.I'd argue about saying that it is "complete nonsense", but you're the bossPS : are you angry or something ?--------------------SCWCD Wall of Fame SCBCD Wall of FameAll roads lead to JavaRanch

   
   
   
   
   
      quote:Originally posted by Satou kurinosuke:I'd argue about saying that it is "complete nonsense", but you're the bossActually, no I'm not. When chiding someone for naming convention violations, or being not nice,thenI'm the boss.When answering questions, I'm just a contributor like anyone else. So if you disagree with me, feel free to say so. I would however, ask that if we are going to discuss the merits of scoped variable usage in JSPs, that another thread be started. We've already hi-jacked Linda's poor thread pretty badly.quote:are you angry or something ?Of course not. Though some peoplehavesaid that I tend to "sound" angry when writing... but be assured that it is not so.Perhaps it's because I am outspoken when I hear what I think is rubbish. But angry? No.[ April 11, 2006: Message edited by: Bear Bibeault ]--------------------[Smart Questions] [JSP FAQ] [Books by Bear]  [Bear's FrontMan] [About Bear]

   
   

 
   
      quote:Though some people have said that I tend to "sound" angry when writing...funny, I've been told the sameThanks for the reply.--------------------SCWCD Wall of Fame SCBCD Wall of FameAll roads lead to JavaRanch


Related Links

some query abt containers
code for uploading file
JSP Struts/JSTL Form problem
accessing .class file from jsp
ListBox Display
Integer.parseInt
unable to load class
Can resolve symbol request
Help needed to send email using jsp
New to jsp can anybody give online resources
JSP Documentation
jsp
Is it possible to hide JSPs from users?
JSP
Problem with precompiling my JSP pages.
Date and Time - Session Problem