Before rating JSP2 I rate my self 5 on (1 ..10) scale of JSP programmer. Here are my views. I liked the old approach. The old approach of <% %> is quite intuitive. Old approach is in synch with the competing technologies like ASP. If one switches between ASP and JSP then switching is easier. I do not know the realistic advantages of the new approach. So why do I re-learn some thing which I was already knowing.
Sun should make things easier, for developers and should also work in the direction of reducing the development time. I would appreciate if it provides some thing like .Net forms so that my productivity increases. Bhavdeep -----Original Message----- From: Erik Beijnoff [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 14, 2003 7:59 PM To: [EMAIL PROTECTED] Subject: Jsp syntax, style and coding conventions I'm interested in getting some feedback on what coding conventions and best practises people are using on this list. Below I've provided a short page that is a simple example of a login page for a web application. When you look at examples, tutorials and discussions on the web, the JSP provided usually doesn't look like this. As far as I've seen, it's far more common to use the "old" ways of doing things, such as <%=...%> and often <%if%>...<%else%> statements and so on. Granted, JSP 2.0 isn't even final yet, but I like it and code almost exclusively this way. Those of you who are familiar with this way of coding, do you find it easier, or do you think it makes the view more complicated than neccessary? Those of you who are NOT familiar with JSP 2.0, do you find the syntax awkward, or do you see a point in doing it the way shown below? Actually this page doesn't really show the way I code, since I have the skin part of the rendered html page separated from the content, but I think the example below is a little bit easier to understand if I show just one JSP document instead of two. I'd gladly explain exactly what is happening below, if you are interested in a deeper understanding of exactly what the page is doing, but in short: it is a login page with separated message bundles specified by the users language setting, and integrated validation and error messaging for the form fields. Regards Erik Beijnoff Addsystems ------------------------------------------------------------------------ ---------------------- <?xml version="1.0" encoding="ISO-8859-1"?> <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:c="http://java.sun.com/jstl/core_rt" xmlns:st="http://com.haywire.stingray.tag" version="2.0"> <jsp:directive.page contentType="text/html" pageEncoding="ISO-8859-1"/> <jsp:text> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "XHTML1-t.dtd" > </jsp:text> <c:set value="${requestScope['com.haywire.stingray.state.object']}" var="state" scope="page"/> <c:set value="${state.user}" var="user" scope="page"/> <c:set value="${user.locale}" var="loc" scope="page"/> <c:set value="${state.msgBundles['page']}" var="msgPage" scope="page"/> <html xml:lang="en"> <head> <style type="text/css"> @import url(${user.color}); @import url(${user.font}); </style> <title>${st:msg(msgPage, loc, 'title')}</title> </head> <body> <div style="text-align:center;"> <div style="font-size:24px;">${st:msg(msgPage, loc, 'title')}</div> ${st:actionResult(state, loc)} <form action="${action['login'].path}" method="post"> <p>${st:msg(msgPage, loc, 'name')}</p> <p><input name="username" type="text"/></p> <p class="error">${st:validateResult(state, loc, 'username')}</p> <p>${st:msg(msgPage, loc, 'password')}</p> <p><input name="password" type="text"/></p> <p class="error">${st:validateResult(state, loc, 'password')}</p> <input type="submit" value="${st:msg(msgPage, loc, 'login')}"/> </form> </div> </body> </html> </jsp:root> ------------------------------------------------------------------------ --------------------- =========================================================================== To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant archives, FAQs and Forums on JSPs can be found at: http://java.sun.com/products/jsp http://archives.java.sun.com/jsp-interest.html http://forums.java.sun.com http://www.jspinsider.com =========================================================================== To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant archives, FAQs and Forums on JSPs can be found at: http://java.sun.com/products/jsp http://archives.java.sun.com/jsp-interest.html http://forums.java.sun.com http://www.jspinsider.com
