Menu
  • HOME
  • TAGS

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

jsp,localization,jstl

A message in the format ???key??? means that the message associated with the key couldn't be found. This can mean that you typo'ed the key, or that the key is absent in the bundle file, or even that the whole bundle file is absent as resource in runtime classpath. Given...

How to use JSTL within JSP declaration

java,jsp,jstl,jsp-tags,scriptlet

This is because the generated code for the scriptlet <% %>goes in the service method which is like called again and over the same object using multiple request threads Whereas <%!, goes into the global class space or simply to declare methods and variables global for a JSP page. Hence...

JSTL formatDate ignoring locale

java,localization,jstl

I would just change the scope to session as below <fmt:setLocale value="fr_FR" scope="session"/> Date in France: <fmt:formatDate value="${now}" dateStyle="full"/> <br/> <fmt:setLocale value="en_US" scope="session"/> Date in US: <fmt:formatDate value="${now}" dateStyle="full" /> <br/> ...

Tag doesn't work

java,jsp,jstl

I fix it, using: <c:if test = "<%= !Users_processing.isUserAuth(request) %>"> Thank's all....

After adding JSTL to pom.xml, JSP doesn't run anymore and returns as plain text

jsp,maven,tomcat,jstl

Finding the right java libraries on maven, especially for jsp, is a royal pain, i'm using these in my pom.xml and it's working okay, try this. <!-- Standard JSP libraries --> <dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>jsp-api</artifactId> <version>2.2.1-b03</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax</groupId> <artifactId>javaee-web-api</artifactId> <version>7.0</version>...

Accessing JSTL varStatus in JSP Expression

java,jsp,jstl,el

The variable ctr created in the page scope. To access page scope variable in JSP expression you can use pageContext implicit object. <table> <% pageContext.setAttribute("questions", Questions.QUESTION_ARRAY); %> <c:forEach var="question" items="${questions}" varStatus="ctr"> <tr> <td> <%=Questions.QUESTION_ARRAY[((LoopTagStatus)pageContext.getAttribute("ctr")).getIndex()]%> </td> </tr> </c:forEach> </table> But it seems ugly if you are using it with JSTL forEach...

Prevent display of Arraylist values twice in java

java,jsp,arraylist,jstl

It looks like problem is because of the following line in your java class. ArrayList<Double> ref_jsp = new ArrayList<Double>(); You have declared ref_jsp as class level variable, move it inside the method public ArrayList<Double> refernece(String name). It is happening because you are calling your referenece method twice from the jsp....

Quote issues reading properties file using fmt:message in JavaScript

java,jsp,jstl

You could use the same technique as handlebars: put your messages in <script> tags: <script type="text/fmt" id="mykey"><fmt:message key="mykey" /></script> then: alert(document.getElementById("mykey").innerHTML); Or, if you're using jQuery: alert($("#mykey").text()); ...

How do I add for loop index to the JSP variable

jsp,jstl

Ans:1 <c:if test="${!empty link[i].alt}"></c:if> Ans: 2 <c:set var="your_var" value="${link[i.index].credit}"/> ...

Get data from Spring-mvc to jstl

jsp,spring-mvc,jstl

In your action you can do this: ModelAndView modelAndView = new ModelAndView(); modelAndView.addObject("student", student); modelAndView.setViewName("path/to/your/view"); return modelAndView; And your view code is correct. I think this will work....

replace(“\”“, ”“") method alternative using jstl

java,jsp,replace,jstl

I would like to add for the benefit of any new visitors that you'll need to import the corresponding functions tag library as well. The taglib directive in your JSP should look like <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> Then invoke the replace() function as before. <p>Your branch's bank name is...

Login/Logout Session not fully working. JSP

html,mysql,jsp,jstl

First you should consider using Java EE security, then server will take care of protecting your pages, and you will be able to access logged userID via request.getRemoteUser(). If you prefer your home grown security, then you should test, if the user is logged in based on attribute stored in...

Servlet path is not included in

jsp,url,servlets,jstl

The <c:url> does indeed not take servlet path into account. That's your own responsibility. The <c:url> only takes HttpServletRequest#getContextPath() into account. Either hardcode yourself: <c:url value="/web/browse" /> Or inline result of HttpServletRequest#getServletPath(): <c:url value="${pageContext.request.servletPath}/browse" /> Or if you're forwarding, inline result of RequestDispatcher#FORWARD_SERVLET_PATH: <c:url value="${requestScope['javax.servlet.forward.servlet_path']}/browse" /> Wrap if necessary in...

How to save many objects in a spring

java,spring,jsp,jstl,spring-form

The elements of a Set cannot be accessed by index. You will need to add methods which return a List wrapping your set. @Component @Entity @Table(name="menu") @Configurable public class Menu implements Serializable{ .... @OneToMany(mappedBy="menu", fetch=FetchType.EAGER) private Set<VoceMenu> voceMenus; public Set<VoceMenu> getVoceMenus() { return voceMenus; } public void setVoceMenus(Set<VoceMenu> voceMenus) {...

How can I concatenate a string inside loop in JSTL/JSP

jsp,java-ee,jstl

Use it like <c:set var="myVar" value="${myVar}${empty myVar ? '' : ','}${currentItem}" /> TEST (Sorry) For lack of time, just inserted in my project. <select> <c:forEach var="row" items="${Friends.rowsByIndex}"> <option><c:out value="${row[0]}"/> <c:out value="${row[1]}"/></option> <c:set var="myVar" value="${myVar}${empty myVar ? '' : ','}${row[1]}" /> </c:forEach> </select> <c:out value="${myVar}"/> Look here on the output next...

JSTL nested expression issue in JSP

jsp,jstl

You don't need to nest it like that. Just write as one expression: ${dataTableVo.orderList[status.index].mtocCode} ...

JSTL - Exists the remove-attribute for put-list-attribute?

java,jstl,tiles,apache-tiles

Thanks John Lee for your answer. But there is little problem: template.jsp is loaded for every page, and I want to exclude custom.js for specific pages, not all pages (if it were the case then I wouldn't include custom.js in jsExtra in ther first place). But taking your idea as...

How to determine if object in a list implements a class using JSTL

java,jstl

You can list the interface that an object implements with Class.getInterfaces(). This can be used in the JSP as this: <c:set var="isComparable" value="false" /> <c:forEach var="interface" items="${yourobject.class.interfaces}"> <c:if test="${interface.name eq 'java.lang.Comparable'}"> <c:set var="isComparable" value="true" /> </c:if> </c:forEach> However, as Sotirios Delimanolis and Robin Jonsson said, this is a very messy...

Drag and drop feature in jsp using jquery

jquery,jstl

It is due to fact that you are initializing draggable with id selector , $( "#widgetJS" ).draggable({ But, In your JSP code , <c:forEach var="widget" items="${allBaseWidgets}"> <div id="widgetJS" title="${widget.name}" class="ui-draggable ui-draggable-handle"> <img src="${widget.imageUrl}" width="20" height="20" alt="${widget.name}" /> <div class="widget-info"> <h2 class="widget-title">${widget.name}</h2> <p class="id">${widget.id}</p> </div> </div> <br/> </c:forEach>...

Converting null to an empty String in Struts 2

jsp,cookies,struts2,jstl,ognl

It seems that your code is based on this answer to another question of your. In this code: <s:set var="name">${cookie["name"].value}</s:set> <s:textfield name="name" value="%{#name}" /> #name is the <s:set> variable's name, NOT the cookie name. To make it clear: <s:set var="foobar">${cookie["name"].value}</s:set> <s:textfield name="name" value="%{#foobar}" /> Then, your attempt to check the...

Why can or not access ?

jsf,primefaces,foreach,datatable,jstl

The <c:forEach> should work with value="#{item.gamesEntered}" rather than the full string but it does not. JSTL tags run during view build time, building JSF component tree. JSF components run during view render time, producing HTML output. So at the moment <c:forEach> runs, <p:dataTable> hasn't run and its var is...

Can I somehow call JSTL function from JavaScript file?

javascript,jstl,jsp-tags

You can use DWR for that cause. An old framework but still holds good if that is what exactly you are looking for in your question. http://directwebremoting.org/dwr/index.html DWR is a Java library that enables Java on the server and JavaScript in a browser to interact and call each other as...

Iterate only few elements inside a jstl foreeach

jsp,foreach,jstl

end="<%= al.size()-2 %>" the last element you want should be al.size()-2, according to array's index...

Why ${!blabla.blibli} returns true in JSTL even if blabla doesn't exist?

java,jsp,jstl

JSP EL is NULL friendly, if given attribute is not found or expression returns null, it doesn’t throw any exception. For arithmetic operations, EL treats null as 0 and for logical operations, EL treats null as false. So when you are trying "!" for the variable which is not found...

Not able to properly obtain selected checkboxes through javascript

javascript,jstl

I do not believe there is any property called "assignments" on a form by default. What you want to be using is something on the lines of var inputs = document.forms[0].getElementsByTagName("input") for (var i=0; i<inputs.length; i++) { if (inputs[i].type === "checkbox" && inputs[i].checked){ // do your thing } } ...

In MVC passing a list from JSP to the Controller

spring,jsp,model-view-controller,jstl

The forEach tag and attributes are case sensitive. <c:forEach items="${contactForm.contacts}" var="contact" varStatus="status"> <c:out value="${status.index}" />: <c:out value="${contact}" /> </c:forEach> It's possible the error messages generated by Eclipse are misleading. It's also possible the error is originating from somewhere else on the page. If this does not resolve the problem, post...

Adding JSTL to jsp (Tomcat 8)

java,jsp,tomcat,jstl

You need to add jar for the jstl library in your classpath. If you are using maven, then add this dependency. <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> Add this to your pom.xml....

How to avoid Default value ([email protected]) for textfield in struts2

jsp,struts2,jstl,ognl

You should not use scriptlets in the code as @AleksandrM is mentioned, but you could use JSTL in the following way <c:set var="remarks"><%=sampletext%></c:set> <s:textfield value="%{#attr.remarks}"/> ...

Internationalization using resource bundle properties in JSP, non-Latin text becomes Mojibake

java,jsp,utf-8,internationalization,jstl

Properties files are as per specification read using ISO-8859-1. ... the input/output stream is encoded in ISO 8859-1 character encoding. Characters that cannot be directly represented in this encoding can be written using Unicode escapes as defined in section 3.3 of The Java™ Language Specification; only a single 'u' character...

Unterminated <c:if tag

java,jsp,jstl

Correct your <option> tag. Attribute test is missing. <option value="${role.roleId}" <c:if test="${role.roleId == 'curLrRoleId'}">selected="selected"</c:if>>${role.name}</option> ^ ...

How to populate the dropdown list from sql server database using LinkedHashMap in java

java,sql-server,jstl,html.dropdownlistfor,linkedhashmap

There are two problems with your code. First, every reference mapping needs to have its own List. Currently, the list is being shared and hence both the reference entries would show all the dates. Change the code as rs = stmt.executeQuery(sql); while (rs.next()) { List<String> list = new ArrayList<String>(); list.add(rs.getString(2));...

JSTL not printing my passed attribute from servlet. Is scope or not accessing doGet() the issue?

jsp,servlets,foreach,jstl

You need to perform the GET request on the controller, not on the view. I.e. the URL which you see in browser's address bar must be the servlet URL, not the JSP URL. This way the servlet's doGet() will be invoked. First move the testPost.jsp file into the /WEB-INF folder...

jsp is not iterating over Linkedhashmap sent by servlet

java,jsp,servlets,jstl

The above code is perfectly fine. Just one line has to be added to the jsp file <%@ page isELIgnored="false"%> ...

JSTL Hashmap and dynamic key

java,jsp,servlets,jstl

You're gonna be mad at yourself, but .... <c:forEach var="secCategories" items="${categoryMap['cata']}"> should be <c:forEach var="secCategories" items="${categoryMap[cata]}"> You don't want the literal string "cata" being the key, you want the value of the cata page property being the key. :)...

Use jstl core as a local resource

java-ee,jstl,libraries,taglib

Nevermind, I have resolved my problem. People coming from outside can load the libraries. Only people from the server (so, no one) can't. ...

How can i check if a param exists with jstl?

jsp,jstl

<s:if test="%{#parameters.itemId == null}"> <fmt:message key="Add" /> </s:if> <s:else> <fmt:message key="Edit"/> </s:else> ...

Print an array in a table using JSTL

arrays,jsp,jstl

Try like this, insert tr tags when index reaches 5th element: <tr> <c:forEach items="${dataName}" var="namedata"> <td class="body" valign="top" align="left"><b><c:out value="${namedata}"/></b></td> </c:forEach> </tr> <c:forEach items="${proteinList}" var="result" varStatus="proteinCount"> <c:if test=((proteinCount.count+1)/5)=0> <tr> </c:if> <td class="datafield" valign="top"><c:out value="${result}"/></td> <c:if...

javax.el.PropertyNotFoundException: Property 'role_id' not found on type model.Role

java,jsp,servlets,jstl

You have use the property role_id <c:out value="${role.role_id}"></c:out> but you don't have such property. To be a property role_id you need to generate getter and setter for name role_id. ...

Access the reports on Jasper Server through URLs embedded in JSP of my application

java,jsp,jasper-reports,jstl,jasperserver

Try this maybe. <c:import var="data" url="http://localhost:8080/jasperserver/flow.html?_flowId=viewReportFlow&standAlone=true&_flowId=viewReportFlow&ParentFolderUri=%2Freports%2FGraphD&reportUnit=%2Freports%2FGraphD%2FMainReport1&j_username=jasperadmin&j_password=jasperadmin"/> <c:out value="${data}"/>

How to show category dropdown on add product page in using Javaee jsp servlet jpa jstl ejb?

jsp,java-ee,servlets,ejb,jstl

i made this work.. don't know exactly why/how it work but the solution is here ...in case someone need .. someday.. <c:forEach var="category" items="${categories}" varStatus="iter"> <option value="${category.id}">${category.name}</option> </c:forEach> gave it a try..it worked...

How to write for each statement in jstl?

jsp,jstl

You can do it by: <c:forEach varStatus="loop"> <c:if test="${loop.index >=0 && loop.index <=5}"> </c:if> </c:forEach> ...

i am passing a model class object but it print ad normal object

hibernate,spring-mvc,jstl

Please go through the Hibernate documentation: https://docs.jboss.org/hibernate/orm/3.6/reference/en-US/html/queryhql.html Queries can return multiple objects and/or properties as an array of type Object[] If you would like to return Subtab objects then change your query to SELECT s FROM Subtab s ... Also please use bind variables in your query as you will...

JSP - error java.lang.String does not have property

java,jsp,jstl

The problem is with this line: <c:set var="list" value=" <%=eng.selectFromDb.appLayer.MotoBO.getAll() %> " /> You may NOT use scriptlet expressions inside JSTL attributes. You should never use scriptlet expressions at all. Accessing the DB should be done in Java, from the controller. And the result (the model) should be stored in...

How to populate checkbox in JSP

html,jsp,jstl

Use this: ${enabled?'checked="checked"':''}. And put it outside the value property. It uses a ternary operator to check the value of enabled and return the corresponding string....

Home button for all level of url in java application

java,jsp,tomcat,jstl

You should be able to add a / character and have the URL work in both cases. <a class="...." href="${pageContext.request.contextPath}/">Home</a> ...

Expression lang with JSP/JSTL nesting values [duplicate]

jsp,jstl,el

Obtained the answer for this from JSTL - how to get a value of value? and thus the code went like this: <c:set var="docname" value="docName_${lang}" /> ${record[docname]} ...

JSTL function : ${fn:replace()} Not only replaces with new pattern also adds the original value

java,jsp,jstl

Please try it this way. <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <%@ taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix = "fn" uri = "http://java.sun.com/jsp/jstl/functions" %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body> <c:set var="pat" value="A,B. .C" /> ${pat}</br > ${fn:replace(pat, ",", " ")} </body>...

How to get more Entety from jsp and send list to servlet

java,jsp,servlets,jstl

You need assign same name to checkboxes <input type="checkbox" name="edit" value="${oneBook.id}">Edit book</td> And catch it on Servlet side String[] toEdit = request.getParameterValues("edit"); This way you will get book ids needs to be edit...

jstl bug while comparing strings UTF-8.(Spring Security - principal.username)

java,jsp,spring-mvc,spring-security,jstl

Please try this test page. It works for me. <%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %> <% pageContext.setAttribute( "currentUser", "Андрей"); %> Test page. <c:if test = "${currentUser eq 'Андрей'}" > Yes, they are equal. </c:if> <c:if test = "${currentUser eq currentUser}" > Yes, they are equal. currentUesr is ${currentUser} </c:if> Output:...

How to change a div class dynamically in a loop

css,jsp,jstl

You'll be simply solved by using <c:if> and varStatus . <c:forEach var="themes" items="${Itemlist}" varStatus="status"> <div class="col-lg-3 col-xs-6"> <c:set var="color" value="green"/> <c:if test="${status.index == 1}"> <c:set var="color" value="red"/> </c:if> ... <div id="style" class="small-box ${color}" ></div> </div> </c:forEach> ...

Access to a child object attribute using jstl

spring,java-ee,model-view-controller,jstl,dispatcher

You can use: <jstl:out value="${project.bg.attribute}"/> ...

How to link different URLs to different items in forEach loop in JSP page?

java,jsp,jstl

You can solve your issue by adding a query params to the link, edit with respect to the comment. Note that you cannot access directly the JSP pages that reside under WEB-INF folder. Also, to encode properly the paramters, better construct url like <c:url value="facultyview.jsp" var="url"> <c:param name="name" value="${faculty.name}"/> <c:param...

How to create object in JSP and access it using EL/JSTL?

java,jsp,jstl

I am currently using a ugly solution like below Client c1= new Client(dbc,id); pageContext.setAttribute("c1", c1 ); pageContext.setAttribute("sa", c1.sa ); pageContext.setAttribute("at", c1.sa.at ); And access it using ${pageScope.at.getName()} ${pageScope.sa.getBalance()} Please advice if there are better ways to do this....

Using custom JSTL tags in a Struts tag attribute

jsp,struts2,jstl,ognl

The value that is written by the custom tag can be use as a body of the set tag, which put the value in the value stack, then you can access it via OGNL in the form tag attribute. If the tag is used with body content, the evaluation of...

Contenante string wich contains value of variable and strings in foreach LOOP in JSP and javascript

javascript,jsp,jstl

Use the <c:choose> JSTL tag to branch into an if-else construct based on the loop counter. <c:forEach items="${coordListEvent}" var="cor" varStatus="stat"> <c:choose> <!-- IF --> <c:when test="${stat.count == 1}"> <c:set var="chaine" value="[${cor.longitude},${cor.latitude}]" /> </c:when> <!-- ELSE --> <c:otherwise> <c:set var="chaine" value="${chaine},[${cor.longitude},${cor.latitude}]" /> </c:otherwise> </c:choose> </c:forEach> ...

How to assign html value to variable using jstl c:set?

java,html,twitter-bootstrap,jsp,jstl

You need to enable html mode for the tooltip: data-html="true" See the documentation...

How to write relative url in jsp?

jsp,jstl

You can get application name testApp with this expression ${pageContext.request.contextPath} so try maybe something like <c:url value="${pageContext.request.contextPath}/admin/createCompany/getMediumThumbnail/1"></c:url> You can also try using relative path. So if your URL looks like http://localhost:8080/testApp/admin/contentModeration but you want to access http://localhost:8080/testApp/admin/createCompany/getSmallThumbnail/1 you can use .. to describe parent context of contentModeration which will be...

Adding nested columns to jstl report by datatables dandelion

hibernate,spring-mvc,datatables,jstl,dandelion

You should change to <datatables:column title="Father name"> <c:forEach items="${person.parents}" var="parent"> <c:out value="${parent.father_name}"/> </c:forEach> </datatables:column> The problem you're having is that property="parents.father_name"/> is not using the variable you've set in forEach, rather uses the parents property from the hibernate entity which is a collection...

import bean and call method using jstl in jsp

jsp,jstl

If you're OK with instantiating the dateShort property in the default constructor of your bean, and with using EL, you can do something like <jsp:useBean id="dj" class="mypack.DatatextFormat" scope="session"/> <c:set var="dateDay" value="${dj.date}"/> <c:out value="${dateDay}"/> or simply output like ${dj.date} update after comment <jsp:useBean id="today" class="java.util.Date" scope="page" /> <jsp:useBean id="dj" class="mypack.DatatextFormat" scope="session">...

Set locale for JSTL in Tomcat JVM arguments for testing?

java,tomcat,intellij-idea,jstl

You need to change the client locale, not the server locale. It's the client who's interested in localized web page, not the server. The server has just to respond accordingly on client's request. How to change the client locale depends on the client used. In Chrome for example, you can...

How it work the language retrieval in this JSP page?

java,jsp,java-ee,jstl,jsp-tags

It is the language defined on the server (not on the browser) for the current user session. This is noticed by reading the proper javadoc of Config: Config#get(HttpSession session, String name Looks up a configuration variable in the "session" scope. The lookup of configuration variables is performed as if each...

Why can't i pass map from jsp to Servlet

jsp,servlets,jstl,jsp-tags

You are using submit button to trigger your servlet class. When you press submit button a new request object is created and it will not contain your map object. To resolve this problem you can use session object instead of request object. Note: Same request object transfer through jsp page...

Iterating through and displaying an attribute of an element of a list

html,spring,spring-mvc,jstl

As per my understanding,as you said "I just want to iterate through the list and display all of the attributes" I think this is what you are trying to display ? somefile.java List<Record> recordList = new ArrayList<Record>(); Record record = new Record(); record.setEnvironment("Env1"); Record record1 = new Record(); record1.setEnvironment("Env2"); Record...

The method getPart(String) is undefined for the type HttpServletRequest

java,jsp,servlets,jstl,tomcat7

You have more than one Servlet API jar on your classpath. JSTL is ooooold and you have a bunch of JSTL artifacts in your pom.xml pulling in old servlet versions. Remove javax.servlet:jstl, jstl:jstl, and javax.servlet.jsp.jstl:jstl-api from your pom.xml and try this instead: <dependency> <groupId>org.glassfish.web</groupId> <artifactId>jstl-impl</artifactId> <version>1.2</version> <exclusions> <exclusion> <groupId>java.servlet</groupId>...

Export scoped var from custom JSP tag

jsp,jstl,jsp-tags,var

Use <c:set> with a target on the desired scope map and property on the ${var}. E.g. if you need it to be request scoped: <c:set target="${requestScope}" property="${var}" value="${dfFormattedDate}" /> Or page scoped: <c:set target="${pageScope}" property="${var}" value="${dfFormattedDate}" /> ...

Is there any better approach to generate radio button?

jsp,servlets,jstl,el

Yes, You don't need JSTL. EL is enough. Try this <input type="radio" value="hobby3" name="hobby" ${(hobby == 'hobby3')?'checked':''} /> ...

Read data sent from ajax to jsp page using jstl

ajax,jsp,jstl

All HTTP request parameters are in EL available via implicit ${param} mapping. So, this should do: <c:out value="${param.dishName}" /> <c:out value="${param.dishId}" /> See also: Java EE 5 tutorial - Expression Language - Implicit Objects Unrelated to the concrete problem, do note that there's quite a difference between "JSTL" and "EL"....

Comparing two List values in JSTL tag

java,jsp,if-statement,jstl

there is an extra $. try this: <c:when test="${ commentsList.user.id eq blog.user.id}"> ...

SQL request process with JS

javascript,jquery,jstl

"code_postal is not defined" happens because of this line of javascript: var currentCp = communeListe[i][code_postal]; Javascript thinks code_postal is the name of a variable, but there's no "var codePostal = ..." anywhere in your javascript. Here's what's going on with your JSP page: First, your JSP is rendered. JSP invokes...

Looping through a list of lists using JSTL

java,jsp,jstl

You are iterating the whole list of courses in all schools over and over again, thus repeating the same output as if you called courseList.toString() method multiple times. You should instead iterate over a concrete list of courses in a current school, which most likely (but nowhere stated in your...

javax.el.PropertyNotFoundException: The class 'com.springapp.mvc.Class' does not have the property 'Courses'

java,jstl,el

EL do not look for properties but for getters: public class AnyClass { private String aProperty; private String getAGetter() { // ... } } ${anyClass.aProperty} will fail, ${anyClass.aGetter} will succeed. To transform a getter name into an EL expression, the "get" (or "is") prefix is removed, and the first char...

Combinate JSTL var with Java method

java,jsp,jstl

Never use scriptlet expressions inside JSP tags. In fact, never use scriptlets at all. The JSP tags are designed to use the JSP EL expressions. Not scriptlet expressions. The way to write your code is, assuming facade is an attribute of some scope <c:forEach items="${facade.allDetails}" var="theDetail"> <c:forEach items="${facade.getSomeStuffById('someHardCodedId')}" var="theStuff"> ${theStuff.name}...

Drop Down list Null Pointer JSP to Servlet

java,mysql,jsp,servlets,jstl

The problem is that you're not fulfilling the necessary fields in your DepartmentBean object reference in the dao class. You're only filling people_manager_name field, and in your JSP you're requesting the data for department_id and department_name, which will call DepartmentBean#getDepartment_id() and DepartmentBean#getDepartment_name() methods. Change this in getAllDepartmentName method: while (rs.next())...

Nested JSF Composite Components leading to a Stack Overflow exception

jsf,jstl,stack-overflow,composite-component,nesting

The problem was in the context of the #{cc} and the statefulness of the composite attribute. The #{cc} in any attribute of the nested composite references itself instead of the parent. The attribute being stateful means that the #{cc} was re-evaluated in every child which in turn ultimately references itself...

Least intrusive way of running JSP

java,jsp,jstl,jsp-tags

For actual deployment in your app, you will need access to the back-end, especially the controller classes. There is nothing inherently in the templates themselves that has anything to do with the URLs they will be rendered for. That also means that you need to have some knowledge of Java,...

Problems with innerHTML

javascript,jquery,html,twitter-bootstrap,jstl

You should not use innerHTML because it removes event bindings. In your case you can simply change class names: function changeText(obj) { var element = obj.children[0]; if (element.className.indexOf('glyphicon-plus') > -1) { element.className = 'glyphicon glyphicon-minus'; } else { element.className = 'glyphicon glyphicon-plus'; } } and use it will onclick attribute:...

EL expressions not evaluated anymore after including JSTL in webapp

jsp,jstl,el,web.xml

Yes, i have doctype in web.xml <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "java.sun.com/dtd/web-app_2_3.dtd"; > Remove that <!DOCTYPE> from web.xml and all should be well. When using JSTL 1.1 or newer, you need to assure that your web.xml is declared in such way that the webapp runs...

Persistent authentication filter logging in; not propagating to JSP

jsp,java-ee,jstl,struts,servlet-filters

As it turns out, the filter that I've set up for persistent authentication appears to only run when a Struts action is invoked; as such, it wasn't running on the index page of my site (among other pages), but in my case was instead authenticating when an AJAX call to...

How do I set this map value to null in JSTL?

null,hashmap,jstl

You can just do: value: ${myMap[myId]} <c:set target="myMap" property="${myId}" value="" /> and then in later code you can test if it's empty with: <c:if test="${myMap[myId] is empty}"> and avoid trying to deal with "null" in JSTL. The (probably) better option is to remove it from the map entirely: <c:set var="debug"...

How to bypass signle quote error in javascript?

javascript,jsp,jstl

you can wrap the single quote with double quote, like: var locations = [ [ "Alex's loc", '37.9908372', ] ]; ...

java, JSTL and getting values by key

java,foreach,jstl,hashtable

You should be using variable name assigned to varStatus - 'cipher_loop' and not varStatus itself. Also you should use the index property or the count property to get the current index. (index starts at 0 and count at 1 by default) ${missing_ciphers[varStatus]} should be ${missing_ciphers[cipher_loop.count]} Edit What is the type...

JSTL - Cast Error String to Long

java,jsp,casting,jstl

You have to use the JSTL function taglib, in order to evaluate the size of the List. The . operator is only used for referring bean properties or hash map keys. So, you have to first import the taglib: <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%> and then change the size definition: <c:set...

Problems with select form population in JSP

java,jsp,servlets,jstl

You can do this by two way: 1.Calling Java method inside jsp <% List<Obiekt> list = new Wypelnij().getObiekty(); %> <select> <% for(Obiekt obiekt : list){ %> <option value="1" ><%=obiekt.getNazwa()%><option/> <% } %> </select> 2.Also you can pass list to JSP from Servlet. And with JSTL you can display List<Obiekt> list...

How can I see if a request passed well in a .jsp file?

sql,jsp,java-ee,jstl

Use the JSTL forEach construct to loop over the recordset now. <c:forEach var="row" items="${recordset.rows}"> <tr> <td><c:out value="${row.INSEE_COMMUNE}"/></td> <td><c:out value="${row.NOM_COMMUNE_MIN}"/></td> <td><c:out value="${row.NOM_CC}"/></td> </tr> </c:forEach> Ideally, your data retrieval code should be in the persistence layer, the results of which are then passed to your JSP by a controller servlet. The JSP...

“${fn:escapeXml(parameter)!=null}” is always true

jstl

The reason is simple: escapeXml() returns an empty string when called with null. And an empty string is not null. public static String escapeXml(String input) { if (input == null) return ""; return Util.escapeXml(input); } ...

Need to add elements of an array to a variable of JavaScript in JSP

javascript,arrays,jsp,jstl

First of all, in your code for two arrays you don't want to have square brackets enclosed in the quotation marks. This will make your whole arrays result and result2 to be a Strings. Second, closing bracket is missing for results, opening bracket is missing for results2. Third, you cannot...

How to access fields of case class from JSP?

scala,jsp,jstl,el,case-class

Annotate the fields of your case classes with scala.beans.BeanProperty: import scala.beans.BeanProperty; case class Person( @BeanProperty val name : String, @BeanProperty val age : Int); Now your person class will have methods like getName() and getAge() as well as name() and age(). If you need bean setters, use vars: class Person(...

Ideal strategy for calling bean in Struts 2 development

java,struts2,jstl,ognl,model-driven

The easiest way to use multiple bean models in one action is to aggregate them to the bean returned by getModel() if you are using model-driven interceptor. You cannot use multiple inheritance using the ModelDriven interface. You can use action class instead of ModelDriven, or use both. Actually in Struts...

jsp. enum comparison / equality

java,jsp,jstl,el

this works: <c:if test="${campaign.moderated eq 'TRUE'}"> <a href="#">click me</a> </c:if> ...

Unable to access beans using JSTL

java,jsp,servlets,arraylist,jstl

You have <c:forEach var="patientBean" items="${requestScope['PatientBean']}"> but request.setAttribute("patientBean", patientBeanList); Note that attribute names are case sensitive. So ${requestScope['PatientBean']} will not find the request attribute named patientBean. Because you previously had <td><c:out value="${patientBean.dob}"/></td> where patientBean would actually refer to the patientBeanList, you're going to want to rename a few things. Your request...

Can you make the id dynamic -

java,jsp,jstl,jsp-tags

Try this: <c:forEach var="dashboardDetailObject" items="${dashboardDetail}"> <div id="${dashboardDetailObject.chartName}" style="width: 100%; height: 400px;"></div> </c:forEach> dashboardDetailList changed to dashboardDetailObject...

JSTL foreach for list in list

java,foreach,jstl

In the forEach loop in JSTL, the var is used as a reference to each element in the list of items in items. These two values should be different. It is essentially like writing for (Object event : pagingSet.events) in Java (code won't compile, just pseudocode). Change your code to...