Intermediate JSP

In this LDS Java Stack training we will build on the Introduction to JSP training, and discuss some more advanced concepts and best practices. Some of the main topics will include the Expression Language (EL), Taglibs, and templating. This is going to be a party you will not want to miss!


  • Basic knowledge of Java language.
  • Basic knowledge of XML syntax and structure.
  • Must have previously completed the Introduction to JSP training.
  • A workstation running Windows, Linux, or Mac OS.

Slide Deck




Expression Language (EL)

  • Value and method expressions
  • Operators
  • ...


  • Goals
  • Usage
  • Common taglibs (core, spring, ...)

Custom Taglibs

  • Creation
  • Functions
  • Taglets (tag files)
  • Templating

Expression Language (EL) Presentation

Get Adobe Flash player

Lab 1 Expression Language (EL)

Demonstrate use of implicit objects, arithmetic operators, and ternary conditional

  • Download and install the following application:‎
    • Unzip the file into your workspace
    • In the LDSTech IDE go to File -> Import... -> Maven (expand) -> Existing Maven Projects -> Next
    • Browse to the unzipped project and press Finish
    • Test that the application runs
      • Right click on project and select Run As -> Run on server
      • Select or manually define a new Tomcat 6.0 Server (not an LDSTech server)
        • This will be found in Apache (expand) Tomcat v6.0 Server
  • Now, for the lab, when you access the application append an age request parameter on the url
    • Such as http://localhost: 8080/jsp-labs/?age=20
  • Then in the index.jsp page
    • Use EL and param implicit object to get the age parameter
    • Using a ternary operator, check if it is less than 40 (i.e. non-protected class :)
    • If so, print out that they were not supposed to enter their age in dog years, otherwise print some sort of welcome
  • This will look something like the following:
     ${param['age'] < 40 ? "Don't enter your age in dog years." : "Welcome youngster"}

Lab 1 Solution

Get Adobe Flash player

Taglibs Presentation

Get Adobe Flash player

Lab 2 Taglibs

For the lab, use the encoding functions in the Stack to fix the vulnerability

  • Currently there is a Cross-site scripting vulnerability in encoding.jsp
  • NOTE: Some of these will not work in Google Chrome, so use Firefox or IE
  • Open encoding.jsp and look at the code and then attempt to exploit the XSS vulnerabilities with something like following:
    • Exploit the XSS vulnerability in the JavaScript with something like -

http://localhost: 8080/jsp-labs/encoding.jsp?js='billy';})();(function(){alert('I own you!')

      • Note this ends the current JavaScript function and begins a new one that can do anything the original page author could do
    • Exploit the XSS vulnerability in the Html with something like -

http://localhost: 8080/jsp-labs/encoding.jsp?html=<script>alert('You are lucky I am nice.');</script>

    • Try to exploit the XSS vulnerability in the attribute -

http://localhost: 8080/jsp-labs/encoding.jsp?attribute=500" width="500" onmouseover="alert(document.cookie);" src="

  • Modify the page to negate this vulnerability
    • Define this repository:
			<name>Main Approved LDS Repo</name>
    • Add the security web dependency to pom.xml
    • Add the appropriate namespace
    • Utilize the proper encoding function for the given usage with something like the following:
            <%@taglib prefix="ssw" uri="" %>


Lab 2 Solution

Get Adobe Flash player

Custom Taglibs Presentation

Get Adobe Flash player

Lab 3 Custom Taglibs

Utilize taglet templating

  • Create a tag file in WEB-INF/tags named template.tag
    • Add the following content to the tag
          	<!DOCTYPE html>
		<%@tag description="Base Template Tag" pageEncoding="UTF-8"%>
		<%@attribute name="title" required="false" rtexprvalue="true"%>
		<%@attribute name="header" required="false" fragment="true"%>
		<%@attribute name="footer" required="false" fragment="true"%>
		<html xmlns="">
				<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
				Pre header:
				<jsp:invoke fragment="header" />
				<div class="ixf-panels">
					Pre body:
					<jsp:doBody />
				Pre footer:
				<jsp:invoke fragment="footer" />
  • Create a jsp file that utilizes the template tag with something like the following:
	<%@taglib prefix="tags" tagdir="/WEB-INF/tags" %>
    • Override everything possible from the template

Lab 3 Solution

Get Adobe Flash player


Get Adobe Flash player
This page was last modified on 11 August 2011, at 07:36.

Note: Content found in this wiki may not always reflect official Church information. See Terms of Use.