Showing posts with label pom. Show all posts
Showing posts with label pom. Show all posts

Tuesday, July 15, 2014

[Java/Spring/Maven] Making JSTL work!!!!

Here are some settings to check to make sure JSTL works in your project. I'm using JSTL 1.1.2 and

Pom.xml dependencies ( Just dumping all dependencies including non-jstl related ones )

 <dependencies>
   <!-- Spring dependencies -->
 <dependency>
  <groupId>org.springframework</groupId>
 <artifactId>spring-aop</artifactId>
 <version>${spring.maven.artifact.version}</version>
 </dependency>
 <dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-beans</artifactId>
  <version>${spring.maven.artifact.version}</version>
 </dependency>
 <dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-context</artifactId>
  <version>${spring.maven.artifact.version}</version>
 </dependency>
 <dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-context-support</artifactId>
  <version>${spring.maven.artifact.version}</version>
 </dependency>
 <dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-core</artifactId>
  <version>${spring.maven.artifact.version}</version>
 </dependency>
 <dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-jdbc</artifactId>
  <version>${spring.maven.artifact.version}</version> 
    </dependency>       
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-orm</artifactId>
        <version>${spring.maven.artifact.version}</version>
    </dependency>       
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
        <version>${spring.maven.artifact.version}</version>
    </dependency>       
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-tx</artifactId>
        <version>${spring.maven.artifact.version}</version>
    </dependency>      
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>${spring.maven.artifact.version}</version>
    </dependency>               
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${spring.maven.artifact.version}</version>
    </dependency> 
   <!-- JSP, Servlet, JSTL dependencies -->
 <dependency>
  <groupId>javax.servlet</groupId>
  <artifactId>servlet-api</artifactId>
  <version>${version.javax.servlet}</version>
 </dependency>
 <dependency>
  <groupId>javax.servlet.jsp</groupId>
  <artifactId>jsp-api</artifactId>
  <version>${version.javax.servlet.jsp}</version>
 </dependency>
 
 <dependency>
            <groupId>xmlbeans</groupId>
            <artifactId>xbean</artifactId>
            <version>2.2.0</version>
        </dependency>
 <dependency>
  <groupId>javax.servlet</groupId>
  <artifactId>jstl</artifactId>
  <version>${version.javax.servlet.jstl}</version>
 </dependency>
 <dependency>
      <groupId>taglibs</groupId>
      <artifactId>standard</artifactId>
      <version>1.1.2</version>
      <scope>compile</scope>
    </dependency>
   <!--  Codehaus Jackson dependencies -->
   <dependency>
        <groupId>org.codehaus.jackson</groupId> 
        <artifactId>jackson-core-asl</artifactId> 
       <version>1.9.1</version>
    </dependency>    
    <dependency>
        <groupId>org.codehaus.jackson</groupId> 
        <artifactId>jackson-jaxrs</artifactId> 
        <version>1.9.1</version>
    </dependency>    
    <dependency>
        <groupId>org.codehaus.jackson</groupId> 
        <artifactId>jackson-mapper-asl</artifactId> 
        <version>1.9.1</version>
    </dependency>    
    <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-mapper-lgpl</artifactId>
        <version>1.9.1</version>
    </dependency>
    <!-- Jettison -->
    <dependency>
        <groupId>org.codehaus.jettison</groupId>
        <artifactId>jettison</artifactId>
        <version>1.3.1</version>
    </dependency>
    <!-- Apache Datasource -->
    <dependency>
  <groupId>commons-dbcp</groupId>
  <artifactId>commons-dbcp</artifactId>
  <version>1.2.2</version>
 </dependency>
    <!--  Oracle Driver -->
     <dependency> 
         <groupId>com.oracle</groupId>
         <artifactId>ojdbc14</artifactId>
         <version>10.2.0.4.0</version>
     </dependency>
    
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <finalName>myspringproject</finalName>
  </build>
  <properties>
   <spring.maven.artifact.version>2.5.6</spring.maven.artifact.version>
   <version.javax.servlet>2.4</version.javax.servlet>
   <version.javax.servlet.jstl>1.1.2</version.javax.servlet.jstl>
   <version.javax.servlet.jsp>2.1</version.javax.servlet.jsp>
  </properties>

JSP taglibs/charset (utf-8)


<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %> 
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Postman</title>
</head>
<body>

web.xml
The web-app attribute to configure the version might start giving you an error saying that the Dynamic Web Module cannot convert to <some version>. If you encounter this, right-click your project in the Project Explorer, go to the Project Facets, uncheck the Dynamic Web Module, Hit OK, and Update Maven Project. If you have the code below, it will set it as the assign version I believe.


<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" 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">