Matt RaibleMatt Raible is a Web Developer and Java Champion. Connect with him on LinkedIn.

The Angular Mini-Book The Angular Mini-Book is a guide to getting started with Angular. You'll learn how to develop a bare-bones application, test it, and deploy it. Then you'll move on to adding Bootstrap, Angular Material, continuous integration, and authentication.

Spring Boot is a popular framework for building REST APIs. You'll learn how to integrate Angular with Spring Boot and use security best practices like HTTPS and a content security policy.

For book updates, follow @angular_book on Twitter.

The JHipster Mini-Book The JHipster Mini-Book is a guide to getting started with hip technologies today: Angular, Bootstrap, and Spring Boot. All of these frameworks are wrapped up in an easy-to-use project called JHipster.

This book shows you how to build an app with JHipster, and guides you through the plethora of tools, techniques and options you can use. Furthermore, it explains the UI and API building blocks so you understand the underpinnings of your great application.

For book updates, follow @jhipster-book on Twitter.

10+ YEARS


Over 10 years ago, I wrote my first blog post. Since then, I've authored books, had kids, traveled the world, found Trish and blogged about it all.

[Denver JUG] The J2EE 1.4 Web Foundation: Servlets and JSPs

I'm sitting in the Qwest Auditorium right now, in the heart of downtown Denver. It's 7:20 p.m. and Sue Spielman is getting ready to launch her presentation on J2EE 1.4. There is a gentleman who is trying to start a JBoss Special Interest Group - if you live in Denver and are interested - send an e-mail to the DJUG mailing list. I've been here since 5:45 (after driving an hour from DTC) so this better be good. ;-) The Eclipse in Action speaker (David Gallardo) is coming to speak in October. In September, the author of AspectJ is coming in conjunction with Grady Booch. Never heard of him, but judging from the applause - I'm living under a rock.

On with the presentation. Sue thinks that J2EE 1.4 will be released towards the end of this year. Damn, I was hoping for the end of the summer.

What's new in Servlets 2.4?

1. Platform Requirements:

  • HTTP/1.1 - New static constants. HttpServletResponse.SC_FOUND to represent status code 302 instead of HttpSerlvetResponse.SC_MOVED_TEMPORARILY.
  • J2SE 1.3

2. DTD to XML Schemas:

  • Provides easier way to define element structure, element ordering structure is arbitrary under <web-app>
  • New elements in 2.4 XSD: <env-entry>, <resource-ref>, <resource-env-ref>, <jsp-config>

3. Complete event listener lifecycle:

  • New Request Events. Be aware that distributed containers handle listeners a bit different (1 instance per JVM).
    • ServletContext - manage, startup/shutdown, attribute changes
    • HttpSession - creation, invalidation, attribute changes, migration if sessions distributed
    • Request - request coming in or out of scope in a web component, attribute changes
  • javax.servlet.ServletRequestEvent, ServletRequestAttributeEvent
  • new interfaces ServletRequestListener, ServletRequestAttributeListener
  • SessionActivationListener is what you'd use for serializing sessions across a cluster

4. Filter enhancements:

  • Ability to configure filters to be invoked under request dispatcher. What does "under the Request Dispatcher mean?" It means that you can apply filters under RequestDispatcher forward() and include() calls. Defined in web.xml:
  • <dispatcher>REQUEST</dispatcher> and/or FORWARD, INCLUDE, ERROR (REQUEST was the only option in Servlets 2.3)
  • Example: if you have INCLUDE - a request doesn't invoke the filter, a forward doesn't invoke the filter, but an include would.

5. Enhancements for i18n:

  • Two new methods: setCharacterEncoding(String encoding) - do before getWriter() and getContentType().
  • <locale-encoding-mapping-list> - new element in the XSD to provide the deployer with the ability to assign locale-to-charset mappings outside servlet code.
<locale-encoding-mapping>
  <locale>en</locale>
  <encoding>en_US</encoding>
</locale-encoding-mapping>
  • Response encoding for English locales will default to US English (as opposed to the "other" English from Great Britain) ;-)

6. API Improvements added to the ServletRequest to help handle proxy servers: getLocalAddr(), getLocalName(), getLocalPort(), getRemotePort().

7. Other improvements:

  • Distributed sessions must throw an IllegalArgumentException if an object placed in the session can't be serialized
  • Relationship b/w session invalidate/timeout clarified (can now set zero or negative values in <session-timeout>)
  • Deprecation of Single ThreadModel (never used it - did you?)

8. Misc. Clarifications:

  • Welcome files can be servlets
  • Any library files exposed by the container apart from the WEB-INF structure must be loaded by the same classloader w/in any single JVM.
    • Examples include the JARs Tomcat loads from $CATALINA_HOME/shared/lib
    • This should help in avoiding potential ClassCastExceptions

As I expected, there still is now way to get the user's requested URL with container managed authentication. Damn.


JSP 2.0

1. Simplifies tag extension protocol

  • SimpleTag interface: doTag(), Tag attribute methods, NO scriplet code allowed
  • SimpleTagSupport class, implements SimpleTag, adds convenience methods: public JspFragment getJspBody(), public JspTag getParentTag()

2. Relationships: .tag file mechanism allows page authors to use JSP syntax to write custom actions

  • Use directive standard syntax: <%@ tag %> instead of <%@ page %>
  • JSP compiler generates custom action code (look in Tomcat's work directory)
  • Flexible packaging:
    • drop .tag file into WEB-INF/tags
    • implicit tag library generation
    • can still write a TLD if you want, or TLD in a JAR file

3. EL Functions: simple function invocations, defined in tag libraries, but it's a fair amount of work - like writing a TLD file and .java source file.

4. Expression Language:

  • . and [] operations access JavaBean properties and Collection elements
  • ${books.title}, ${books[title]}, ${books["JSTL Practical Guide"]}
  • Automatic type conversion
  • Ability to specify defaults (i.e. in case of null)
  • EL can access Cookies, request params, headers, scope variables and others

5. XML-based JSPs:

  • .jspx and .tagx for pure XML versions
  • no more <jsp:root> just use namespace: xmlns:jsp=http://www.sun.com/JSP/Page
  • For full list of XML features - see section 6.

JSTL (Java Standard Tag Library)

  • Over 42 standard custom actions available for common tasks needed by page authors
  • JSTL will become rev 1.1 in the J2EE 1.4 release

1. Core features:

  • Control flow: for each, conditionals
  • URL management: encoding, ftp, http
  • Formatting and i18n: date, time, numbers, locales
  • XML: transformations and XPath
  • Database support: queries, data sources, transactions
  • 4 custom action libraries: core, xml, i18n formatting, sql.

Man, Sue really knows her stuff. This was a very enjoyable presentation for me and I'm glad I came. Too bad JSPs can't be used as templates like Velocity - that would be sweet! Of course, I like Velocity and it is easy to use - but I've never implemented it from scratch. I do hope to in Moblogger and Struts Menu, but who knows when that will happen.

Update (7/17/2003): Presentation slides from this are now available for download:

  • July 9 - Basic Concepts: Scott Davis Apache Xerces - XML Parse (PowerPoint and samples)
  • July 9 - Main Speaker: Sue Spielman J2EE 1.4 Web Foundation (PowerPoint)

Posted in Java at Jul 09 2003, 11:15:44 PM MDT Add a Comment
Comments:

Post a Comment:
  • HTML Syntax: Allowed