Showing posts with label JSP. Show all posts
Showing posts with label JSP. Show all posts

7 June 2018

Java EE web technology version history (updated)


JSR numbers are included as links.
Servers are webcontainers.Take care, web containers do not include JSF. You have to add it yourself or use an enterprise application server. Enterprise application servers are included in the
complete Java EE version overview.

Java EEservletJSP     ELJSTLJSF    WebSocketMVCServer       What’s new
2.1
1.0

iPlanet
jetty 1
ServletContext, RequestDispatcher
1.2
2.2
1.1
tomcat 3.3
jetty 3
war
1.3
53 2.3
53 1.2
tomcat 4.1
jetty 4
filters
1.4
154 2.4
152 2.0
1.0
52 1.1
tomcat 5.5
jetty 5
5
2.5
245 2.1
2.1
1.2
127 1.2

tomcat 6
jetty 6
annotations
6
315 3.0
2.2
2.2

314 2.0

tomcat 7
jetty 8
asynchronous servlets, EL method calls, more...
7
340 3.1
 341 3.0

344 2.2
356 1.0

tomcat 8
jetty 9.1
HTML 5, non blocking (Listener) servlet IO
8
369 4.0


372 2.3
1.1
371 1.0tomcat 9 HTTP/2

21 June 2012

Expression Language 3.0 is in public review

The Expression Language (EL) is widely used in JSP and JSF. With version 3 the EL now becomes an independent specification. The EL v3 (JSR 314) is in public review until the end of July. It will be released in sync with Java EE 7 (Update: EL 3.0 was released in may 2013). New features include:

  •  As an independent specification, EL now comes with a standalone API, allowing usage outside a web container.
    • You can write your own ELProcessor. The source code is available, but I wish they had put the javadoc for  browsing at the project site as well.
  • Java 8 stuff
    • Lambda expressions
    • Collection literals follow proposed Java 8 syntax
      • List: [1, "two", 3.0]
      • Set: {1, 2, 3}
      • Map: {"one":1, "two":2, "three":3}
    • Collection streaming
  • Assignment operator (=) for changing values:
    • ${customer.name = 'Jan'}
  • String concatenation: + or cat operator
    • ${‘Welcome ‘ += customer.name += ‘ to our site’}.
  • Support for static references using the T construct (Type). 
    • By default only java.* and javax.* packages are available, but you can modify this using the EL API.
      • ${T(java.util.Calendar).APRIL}
      • ${T(java.util.Calendar).getInstance()}
    •  You can call constructors as a static method without a name. To call the default Calendar constructor:
      • ${T(java.util.Calendar).()}
    • For java.lang you can use the class without using the T construct
      • ${Boolean.TRUE}

19 December 2010

Adding JSTL/JSP EL to your web applicaton (updated)

Quite some environments do not come with JSTL: Eclipse for JEE (Galileo), Tomcat 6, Jetty 6... Follow these steps to add them:

  1. Add JSTL
    Grab the JSTL API (jstl-api.jar) and JSTL implementation (jstl-impl-1.2.jar).
    Add the jars to your Container (e.g. Tomcat) lib directory (or your webapp lib).
    Alternatively add them using maven dependencies:
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>jstl</artifactId>
      <version>1.2</version>
    </dependency>
    
  2. Make sure the web-app root element in web.xml supports at least servlet 2.4/JSP 2.0
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
     http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
    If you use <taglib> elements in web.xml, make sure they are embedded in a <jsp-config> element.

1 October 2010

jspx document

Minimal solution of list headers JSTL exercise (SL-314-EE6 mod 6 lab 1) without any <%…%>  tags (e.g. for taglib declaration).
The document must be saved in a .jspx file (e.g. index.jspx):

<html xmlns:jsp="http://java.sun.com/JSP/Page"
      xmlns:c="http://java.sun.com/jsp/jstl/core">
  <jsp:directive.page contentType="text/html;charset=UTF-8"/>
  <head><title>Header jspx page</title></head>
  <body>
    Request headers:
    <ul>
      <c:forEach var="zheader" items="${header}">
        <li>${zheader}</li>
      </c:forEach>
    </ul>
  </body>                                     
</html>

25 May 2010

JSP history of writing bean properties

  • JSP 0.9

<% ActionForm form = (ActionForm) request.getAttribute(”LoginForm”); %>
<%= form.getUserName()%>

  • JSP 1.0

<jsp:useBean id=“form" class=“be.uniway.LoginForm" />
<jsp:getProperty name=“form" property=“userName" />

  • Struts

<bean:write name=“loginForm" property="userName"/>

  • JSP 1.2

<c:out value} ="${loginForm.userName}">

  • JSP 2.0

${loginForm.userName}

16 May 2010

JSTL/JSP EL alternate Struts excercise solution

The De Post/PMC excercises (and the Struts blank sample application) are based on

  • Struts
    • tags-bean
    • tags-logic
    • tags-html
  • JSP scriptlets
In this post we will show how to move this to
  • Struts
    • tags-html
  • JSTL
  • JSP expression language
To enable JSTL/JSP/EL support in your application follow these instructions. Here’s the table from the excercise rendered with JSTL/JSP EL:
<c:forEach  var="product" items="${List}"  varStatus ="status">
  <tr class="${(status.index%2==1)?'odd':'even'}">
    <td>
      <html:link action="<%=modify%>" paramId="id" paramName="product" paramProperty="id">
        <html:img srcKey="icon.edit" altKey="icon.alt.edit" border="0"/>
      </html:link> 
    </td> 
    <td>
      <html:link action="<%=remove %>" paramId="id" paramName="product" paramProperty="id">
        <html:img srcKey="icon.trash" altKey="icon.alt.trash" border="0"/>
      </html:link>
    </td>
    <td> ${product.name}</td> 
    <td> ${product.description}</td>
  </tr>
</c:forEach>

25 May 2009

JSP/servlet authentication

You can define authentication in the web.xml deployment descriptor of a web application.

  1. Define roles
    <security-role>   
      <role-name>admin</role-name>    
    </security-role>    
    <security-role>    
      <role-name>boss</role-name>    
    </security-role>
    User definition is web container dependent. 
  2. Define protected resources
    <security-constraint>   
      <display-name>Goodies</display-name>    
      <web-resource-collection>    
        <web-resource-name>Goodies</web-resource-name>    
        <description/>    
        <url-pattern>/Cookies</url-pattern>    
        <url-pattern>/Smarties/*</url-pattern>    
      </web-resource-collection>    
      <auth-constraint>    
        <description/>    
        <role-name>admin</role-name>    
        <role-name>boss</role-name>    
      </auth-constraint>    
    </security-constraint>
    Take care:
    • Is only guaranteed for cookie based sessions
    • Does not apply to forward and include
  3. Define authentication method
    <login-config>   
      <auth-method>FORM</auth-method>    
      <realm-name/>    
      <form-login-config>    
        <form-login-page>/login.jsp</form-login-page>    
        <form-error-page>/login-error.jsp</form-error-page>    
      </form-login-config>    
    </login-config>
    The authentication form is supposed to have a POST action called j_security_check and j_username and j_password input fields.
    Other HTTP authentication methods are
    • BASIC: clear text password (base64 encoded)
    • DIGEST: hashed password (works in Firefox and IE 7+)
    • CLIENT-CERT: mutual certified SSL