jstl

JSTL Access Integer/Long key in Hash Map

橙三吉。 提交于 2020-01-05 03:18:20
问题 I am facing some problem in using EL in JSTL and not able to access Java Hash Map as I would like. I am aware that in EL the key, if Integer gets accessed as Long. I have following hash map definition that I am trying to access in JSTL - Map<Long, Object> testMap = new HashMap<Long, Object>(); In JSP page, I need to check if the map contains a specific key or not. I attempt to do that by checking if not empty as following - <c:if test='${ ! empty testMap[currObj.currVal]}'> I also access the

Passing form input values as a List of objects from a JSP page to a Servlet

依然范特西╮ 提交于 2020-01-04 15:14:35
问题 Here is a simplified (NOT real world) example. Suppose there is a domain model - a class Movie , which has a List of actors. A class Actor has three fields ( name , birthDate , rolesNumber ). The following code is an illustration of this scenario: Movie.java public class Movie { // some fields private List<Actor> actors; // getters and setters } Actor.java public class Actor { private String name; private Date birthDate; private int rolesNumber; // getters and setters } There is also a JSP

JSTL and hashmap not working

十年热恋 提交于 2020-01-04 11:44:07
问题 In a servlet I have: HashMap eventsByDayNo = new HashMap(); eventsByDayNo.put (new Integer(12), "day 12 info"); eventsByDayNo.put (new Integer(11), "day 11 info"); eventsByDayNo.put (new Integer(15), "day 15 info"); eventsByDayNo.put (new Integer(16), "day 16 info"); request.setAttribute("eventsByDayNo", eventsByDayNo); request.setAttribute("daysInMonth", new Integer(31)); And in a jsp I have: <c:forEach var="dn" begin="1" end="${daysInMonth}" step="1" varStatus="status"> Day Number=<c:out

Binding objects to controls on JSP pages

时光总嘲笑我的痴心妄想 提交于 2020-01-04 05:33:09
问题 I have the following class that I'm using in my Java with JSP applicaton. // public class QuestionBO implements Serializable{ private int questionId; private int testID; private String question; private TutorBO infoAboutTutor; private SubjectBO infoAboutSubject; private TestBO infoAboutTest; private List<AnswerBO> answers; public QuestionBO() { } public QuestionBO(String question) { this.question = question; } getter & setter.... The JSP page has a form where each Question (its String

JSTL c:forEach does not iterate through a collection

泄露秘密 提交于 2020-01-04 02:07:14
问题 Does anyone has any idea, why this code would work: <h:outputText value="#{allocations[0].policyNumber}" /> and this code would work: <c:forEach var="i" begin="1" end="5"> <h:outputText value="aaa"/> </c:forEach> But this code would NOT work (nothing appears in GUI): <c:forEach var="allocation" items="#{allocations}" > <h:outputText value="aaa"/> </c:forEach> I am using namespace "http://java.sun.com/jstl/core". allocations is a collection in java. I have tried everything I could think of and

Can't use JSTL on a simple example

允我心安 提交于 2020-01-03 18:03:28
问题 Here's my current situation: I've created a Maven project from my shell, using this command: mvn archetype:generate -DgroupId=it.my.current.package.example -DartifactId=Example -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false mvn package Then I opened Eclipse, imported the project as a Maven one. I added those dependencies to my pom.xml <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.1.0</version> </dependency>

fmt:message prints key with question marks like so “???login.label.username???”

孤街浪徒 提交于 2020-01-03 17:29:33
问题 I am trying to internationalize my website using JSTL 1.2 based on How to internationalize a Java web application?. Here is the beginning of the JSP file: <%@ page pageEncoding="UTF-8" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <c:set var="language" value="${not empty param.language ? param.language : not empty language ? language : pageContext.request.locale}" scope="session" /> <fmt:setLocale value="$

How to set a cookie in JSTL

笑着哭i 提交于 2020-01-03 17:17:54
问题 I am trying to achieve the below but not sure if its possible and what should the syntax be ? <c:if condition is true> <c:set cookie using JSTL> </c:if> I am thinking ,since cookie is only set on client side and JSTL is used for doing things on server side, it cannot be done. 回答1: You can't set a cookie using JSTL. JSTL doesn't have any tags for this functionality. JSTL runs during generating the HTTP response, while a cookie needs to be set in the HTTP response header long before generating

How to set a cookie in JSTL

大憨熊 提交于 2020-01-03 17:17:08
问题 I am trying to achieve the below but not sure if its possible and what should the syntax be ? <c:if condition is true> <c:set cookie using JSTL> </c:if> I am thinking ,since cookie is only set on client side and JSTL is used for doing things on server side, it cannot be done. 回答1: You can't set a cookie using JSTL. JSTL doesn't have any tags for this functionality. JSTL runs during generating the HTTP response, while a cookie needs to be set in the HTTP response header long before generating

Best Practice for financial calculations using JSTL/Tomcat [closed]

元气小坏坏 提交于 2020-01-03 16:37:14
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 7 months ago . I am building a new ecommerce platform using Tomcat/JSTL/MySQL/etc. I am aware of the various issues related to using floating point calculations - e.g. 12.3456000000000789... I know rounding vs truncation can also be an issue. Without moving all of the business logic into