Using both Thymeleaf and JSP

According to this post on the Thymeleaf forum, you have two solutions. First solution : Remove the suffix property in your bean declaration (<property name=”suffix” value=”.html” /> and <property name=”suffix” value=”.jsp” />) and pass the suffix in the return value of your controllers, e.g. : @RequestMapping(“/view1”) public String thymeleafView(){ return “mythymeleafview.html”; } @RequestMapping(“/view2”) public String … Read more

Can not find the tag library descriptor for “http://java.sun.com/jsp/jstl/core”

Use taglib definition in your JSP or better include it in every page by the first line. <%@ taglib prefix=”c” uri=”http://java.sun.com/jsp/jstl/core” %> There’s also fix jstl-1.2 dependency in your project. Also use servlet specification at least 2.4 in your web.xml. The maven dependencies are (maven is a open source development tool) <dependency> <groupId>jstl</groupId> <artifactId>jstl</artifactId> <version>1.2</version> … Read more

Get all parameters from JSP page

<%@ page import = “java.util.Map” %> Map<String, String[]> parameters = request.getParameterMap(); for(String parameter : parameters.keySet()) { if(parameter.toLowerCase().startsWith(“question”)) { String[] values = parameters.get(parameter); //your code here } }

How to check a boolean condition in EL?

You can have a look at the EL (expression language) description here. Both your code are correct, but I prefer the second one, as comparing a boolean to true or false is redundant. For better readibility, you can also use the not operator: <c:if test=”${not theBooleanVariable}”>It’s false!</c:if>

How to read an excel file contents on client side?

An xlsx spreadsheet is a zip file with a bunch of xml files in it. Using something like zip.js, you can extract the xml files and parse them in the browser. xlsx.js does this. Here’s my simple example. Copied here for convenience: /* Relies on jQuery, underscore.js, Async.js (https://github.com/caolan/async), and zip.js (http://gildas-lormeau.github.com/zip.js). Tested only in … Read more

Why Facelets is preferred over JSP as the view definition language from JSF 2.0 onwards?

True, JSP has some templating capabilities, but the biggest disadvantage of using JSP in JSF is that JSP writes to the response as soon as it encounters template text content, while JSF would like to do some pre/post processing with it. In JSF 1.0/1.1 the following JSF code <h:outputText value=”first”/> second <h:outputText value=”third”/> fourth would … Read more

Where are the generated JSP class files located?

Doubleclick the Tomcat entry in Servers tab in Eclipse. You’ll see something like this in Server Locations section: If you haven’t changed the server path and it thus defaults to Eclipse’s workspace metadata, then the Tomcat’s /work directory is not in Tomcat’s own installation folder, but in the path as shown in the above screenshot. … Read more

Regular expression to remove special characters in JSTL tags

The JSTL fn:replace() does not use a regular expression based replacement. It’s just an exact charsequence-by-charsequence replacement, exactly like as String#replace() does. JSTL does not offer another EL function for that. You could just homegrow an EL function yourself which delegates to the regex based String#replaceAll(). E.g. package com.example; public final class Functions { private … Read more