FAQ Database Discussion Community


Who compiles the taglibs?

jsp,tomcat,compilation,el,taglib
I'm studying a code that mixes, in one JSP archive: java commands, Expression Language commands and Taglibs. So, I know the Java code is transformed in a Servlet, and the EL is compiled by the servlet container. But what about the taglibs? For example: <jsp:useBean id="contact" class="package1.package2.contact"/> Who deals with...

How to override PrimeFaces CSS via external stylesheet

html,css,jsf,primefaces,el
I have the following code on my xhtml page to override default PrimeFaces styling: <h:body> <f:facet name="last"> <h:outputStylesheet library="css" name="main.css" /> </f:facet> ... </h:body> This works fine when I am using a stylesheet, that is stored locally on my server. The Problem is, that I want to include a external...

How to access fields of case class from JSP?

scala,jsp,jstl,el,case-class
When I was a Java programmer my typical approach was to write a POJO with getters and access its fields in JSP through those getters ${pojo.field}. Now I'm trying to use Scala. Case classes looks like a good replacement for POJO's, but scala provides field() getters instead of getField() which...

How to assign values for a list of some objects defined as variable with Spring Expression Language(Or the other expression languages you aware of)

java,spring,expression,el,spring-el
In Spel, it is easy to assign some values for a List property. For example having object foo with a property defined as List, I usually do: SpelParserConfiguration config = new SpelParserConfiguration(true,true); ExpressionParser parser = new SpelExpressionParser(config); Foo foo = new Foo(); EvaluationContext context = new StandardEvaluationContext(foo); parser.parseExpression("barList[1].test='11111111'") .getValue(context); But...

Reference EL function from xhtml located in same jar

maven,jsf,el,taglib
So, I have a jar that contains several common .xhtml files that I use in my web project (JSF2.2 in a Wildfly 8.1 server) as custom components. Also, in the same .jar I have a utility class ( ViewUtils ) that has a function that I call from the .xhtml...

Is it not possible to directly invoke session.getAttribute() with EL?

jsp,el,session-scope
The value for 'email' is set within session scope using session.setAttribute("email", "[email protected]"). To display the value later, the following code was used <c:out value='${session.getAttribute("email")}'> </c:out> This yielded no output on the screen. Note that the necessary packages were imported and that there is no error produced. However, if I re-write...

Is there any better approach to generate radio button?

jsp,servlets,jstl,el
To generate dynamic radio button based on value in hobby.What i does is- request.setAttribute("hobby", null); //values of hobby can be "hobby1" or "hobby2" or "hobby3" or null request.getRequestDispatcher("display.jsp").forward(request, response); In display.jsp I am generating radio button- <tr> <td >Hobby1 <c:choose> <c:when test='${hobby.equals("hobby1")}'> <input type="radio" value="hobby1" name="hobby" checked/> </c:when> <c:otherwise> <input...

How to put data in view scope via EL in JSF page

jsf,jsf-2,el,facelets,view-scope
In my JSF page this works: ${requestScope.put('test', 'data')} ${requestScope.get('test')} This causes exception: ${viewScope.put('test', 'data')} ${viewScope.get('test')} Exception: java.lang.NullPointerException javax.el.BeanELResolver.invoke(BeanELResolver.java:159) javax.el.CompositeELResolver.invoke(CompositeELResolver.java:84) org.apache.el.parser.AstValue.getValue(AstValue.java:157) org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:184)...

on Map causes ClassCastException on java.lang.String

jsf,jsf-2,hashmap,el,classcastexception
private Map<Linha, Long> mapLinhas = new HashMap<Linha, Long>(); for (final Linha linha : this.mapLinhas.keySet()) { final Long idLinha = this.mapLinhas.get(linha); final Unidade b = Cache.getInstance().getUnidade(a); linha.setUnidade(b); } The map values are of Long type, but when I assign it to another Long variable it throws the following exception: 02/02/2015...

unable to get init-parameter from servlet context using EL

java,jsp,servlets,el
I am trying to get value of init parameter defined in web.xml file. But I am getting Http Status 500 exception. code to get init parameter in JSP file: init param: ${pageContext.servletContext.initParameter.mob} web.xml: <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"...

Getting sum using EL and JSP

jsp,sum,el
<% double sum = 0.0; %> <c:forEach var="user" items="${page.content}"> <% sum += $user.grade; %> ${user.grade} </c:forEach> I want get the sum of all user.grade. How to do it?...

Accessing JSTL varStatus in JSP Expression

java,jsp,jstl,el
I have a JSP that imports an interface. The interface has a String[] QUESTION_ARRAY. <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ page import="com.mypackage.message.Questions"%> <table> <c:forEach var="question" items="<%=Questions.QUESTION_ARRAY%>" varStatus="ctr"> <tr> <td><%=Questions.QUESTION_ARRAY[ctr.index]%></td> </tr> </c:forEach> </table> In [ctr.index], it is saying ctr is unresolved. How do I access it inside the expression?...

JSP EL not working - javax.el.PropertyNotFoundException: Property 'name' not found on type java.lang.String

jsp,el
I have a problem with JSP EL that i figure it out. In my Servlet doGet() method i'm using this code to retrieve data from data base : UserServices us = new UserServices(); List<User> users= us.allUsers(); request.setAttribute("users", users); request.getRequestDispatcher("/list_users.jsp").forward(request, response); The Problem is when i use JSP Scriplets & Expressions...

Property 'position' not found on type java.lang.String

jsf,jsf-2,primefaces,el
I am trying to output a primefaces datatable. <p:dataTable var="bi" value="#{ bowlingInfo.hallMastaren} "> <p:column headerText="Position"> <h:outputText value="#{bi.position }" /> </p:column> </p:dataTable> But it won't recognize the data it seems, and throws the below exception. javax.servlet.ServletException: /test.xhtml @13,47 value="#{bi.position }": Property 'position' not found on type java.lang.String I am using primefaces...

Property 'productCategoryName' not found on type java.lang.String

jsf,jsf-2,el
I have checked as much as i can ,but i could not find where the problem is , i have seen few stack overflow Questions related to mine but mostly they all seems missing # . and i have seen somewhere that old version of mojora lib may cause this...

“#{serviceCatalogueController.allMap[category.key]}”: Property 'key' not found on type java.util.HashMap$KeySet

jsf,primefaces,hashmap,el,datalist
I am trying to populate a map with values from inputText and inputTextArea. Also Date. In the backbean I have a map of like Map> Basically, a Category can have many Attributes. These Attributes are input fields. For multiselect, dropdown and single select all i need is to set the...

#{bean.list.size} causes java.lang.NumberFormatException: For input string: “size”

list,jsf,size,el
Here is my xhtml , i have problem with rendered attribute. I get an error about "size" of my list. I want to render the datatable only if some data found.Couldnt find how to fix it.Thank you for your time. <ui:composition template="/pages/admin/admin.xhtml" xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:p="http://primefaces.org/ui"> <ui:define name="center"> <h:form...

How doest EL work with methods and fields of object without knowing its class

java,jsp,el
I can't understand how it works when we do in jsp something like ${someObject.doMethod()} The thing what I don't understand is that we don't define here the class of object but jasper compiles that and this code works. I mean we don't write ${SomeClass someObject.doMethod()} Please, explain how it works....

ModelMap/ModelAndView data is not displayed

java,spring,jsp,spring-mvc,el
I am trying to run spring mvc helloworld example by tutorialspoint.but I am not geeting the modelmap data in jsp page .I had added all the required jars in web-inf/lib folder.I am also using <%@ page contentType="text/html; charset=UTF-8" isELIgnored="false" %> .But still i am not getting data in jsp page....

spring annotation getter for isMethod

java,el
I want to use an is method in my bean instead of a getIsmethod. Is there a way to tell el that the method to use isn't a get method? private boolean isSloAdmin = false; //todo be nice to have it standard isMethod call public boolean getIsSloAdmin() { return isSloAdmin;...

How to get original request URI in EL spring-boot page behind httpd proxypass

apache,spring-boot,el,proxypass,embedded-tomcat-7
I have a spring-boot web application with embedded tomcat, running on port 28081, and httpd configured for proxying like this: ProxyPass / http://localhost:28081/ ProxyPassReverse / http://localhost:28081/ Then in a jsp page I need to pass the full request URL to a silverlight widget;but ${pageContext.request.serverName}:${pageContext.request.serverPort} will resolve to http://localhost:28081. So I...

javax.el.PropertyNotWritableException when using EL conditional operator in value of UIInput

jsf,input,el,placeholder,conditional-operator
I get this error message: javax.el.PropertyNotWritableException: /u/editProfile.xhtml @64,140 value="#{empty userProfile.cfg.gpu or userProfile.cfg.gpu == '' ? usernavmsg.EditMe: userProfile.cfg.gpu}": null The problem is that when the value of a bean property is null the value of an inputText field switches from my ManagedBean property, to a resource string. So I cannot persist...

EL resolver in faces-config.xml

spring,jsf,el,faces-config
While working on a Spring-JSF integration, I'm seeing this entry in faces-config.xml. <application> <el-resolver> org.springframework.web.jsf.el.SpringBeanFacesELResolver </el-resolver> </application> Can someone explain what exactly <application> and <el-resolver> are?...

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

java,jstl,el
Here's my model: public class Class { @ManyToMany(etc etc) @JoinTable(etc etc) public List<Course> Courses; Here's my view: <c:forEach items="${classes}" var="class"> <tr> <td>${class.className}</td> <td> <c:forEach items="${courses}" var="course"> <input type="checkbox" <c:if test="${class.Courses.contains(course)}"> checked</c:if>> ${course.courseName} </c:forEach> </td> </tr> </c:forEach> The view only produces this 500 error:...

My jsp page is not showing output properly

jsp,spring-mvc,el
These are my classes. WebConfig.java: import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.EnableWebMvc; @Configuration @EnableWebMvc @ComponentScan(basePackages="com.pluralsight") public class WebConfig { } HelloController.java: import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; @Controller public...

JSF Composite Component with conditional popup panel

jsf,richfaces,el,composite-component
I'm trying to render a composite component that shows a popup panel based on the outcome of a backing bean method. So far no success. Would appreciate some help. GlassFish 4.1 Mojarra 2.2 RichFaces 4.5.4 Composite Component (conditionalActionLink.xhtml): <ui:component xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich" xmlns:ui="http://java.sun.com/jsf/facelets"...

What exactly is #{component} in EL?

jsf,el,uicomponents
According to https://code.google.com/p/primefaces/issues/detail?id=4720, The ComponentUtils.resolveWidgetVar(String expression, UIComponent component) function is available in Primefaces since 2013. It can be used in EL by the "#{p:widgetVarFromContext(searchExpression, component)}" function. This is useful in case of several components have the same id in different NamingContainer, but are still present in the same view. In...

JSF Property not found exception. porperty not readable

jsf,cdi,el
can someone help out, I just don't get it, the other bean works fine, i'ts just that bean that sucks: BEAN: import java.io.Serializable; import java.util.List; import javax.enterprise.context.SessionScoped; import javax.inject.Named; @SessionScoped @Named class FeedbackController implements Serializable { private static final long serialVersionUID = 1L; private Lecture lecture; private List<Feedback> filteredFeedbacks; public...

JSF NumberFormatException with f:setPropertyActionListener

jsf,datatable,el,jsf-2.2,setpropertyactionlistener
I'm getting this error with f:setPropertyActionListener and i can't figure out why: HTTP Status 500 - For input string: "selectedItem" exception: javax.servlet.ServletException: For input string: "selectedItem" javax.faces.webapp.FacesServlet.service(FacesServlet.java:667) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) root cause: java.lang.NumberFormatException: For input string: "selectedItem" java.lang.NumberFormatException.forInputString(Unknown Source) java.lang.Integer.parseInt(Unknown Source)...

java.lang.NumberFormatException: For input string: “pname”

java,hibernate,java-ee,hql,el
why I always get numberformatexception? I try to retrieve values in my database to my jsp. I want to view my join table in my jsp. I have 2 entities Item Class public class Item { @Id @Column(name="p_id") private String pid; @Column(name="p_name") private String pname; @Column(name="catId") private String catid; public...

jsp/servlet, show different links for admin, user and not logged in user

java,jsp,servlets,el
I found here code which can solve my problem, but I don't have any idead how it works. Code: <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <!DOCTYPE html> <html> <head> <title>Sample Page</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body> <c:choose> <c:when test="${pageContext.request.isUserInRole('admin')}"> <p>Content...

How to use II (or) in EL boolean expression

jsf,el,or-operator
I'd like to conditionally render a component like below: rendered="#{att.attName != 'att1' or 'att2'}" However, that didn't work. I have tried both or and ||, but it evaluates only the left hand of OR condition, so in above case it compares only with "att1" not with "att2" If I change...

Session attribute not responding inside EL expression

java,jsp,el,jsp-tags
I know this may look like a duplicate question. Unfortunately there is no acceptable, working answer. Even the OP was facing a different issue, not what the question it says. POJO class below : private boolean admin = false; private boolean isNormal = false; public void setAdmin(boolean admin) { this.admin...

How to bind a bean's method with package in actionListener?

jsf,el,jsf-2.2,methodexpression
I am pretty much newbie to Java/JSF technology and I've been trying to do simple UIs to understand how things are going on in Java/JSF world. Now I want to bind a ManagedBean's method with its package name to a CommandButton's actionListener. Example: index.xhtml ... <h:commandButton actionListener="#{com.acme.myclass.MyMethod}" ... ... MyClass.java...

Identifying and solving javax.el.PropertyNotFoundException: Target Unreachable

jsf,cdi,el,managed-bean
When trying to reference a managed bean in EL like so #{bean.entity.property}, sometimes a javax.el.PropertyNotFoundException: Target Unreachable exception is being thrown. There seem to be three different kinds of messages: Target Unreachable, identifier 'bean' resolved to null Target Unreachable, 'entity' returned null Target Unreachable, 'null' returned null What do they...

Set Session attribute using expression language

jsp,session,attributes,el
How I can set an attribute in a session using expression language in the following code <body> <h1>Hello ${param.name}!</h1> <% String n = $ {param.name} %> <% session.setAttribute("user", n); %> <a href="process.jsp">visit</a> </body> ...

EL expressions not evaluated anymore after including JSTL in webapp

jsp,jstl,el,web.xml
There's a small problem with my servlets/jsp web application. I'm trying to use jstl in jsp page. When I use any tag for example: <c:out value="${command}"/> it shows me ${command} in my browser instead of parameter 'command' value. I'm using maven (and I guess the problem is here). Here is...

How can I pass a list literal to f:selectItems?

jsf,el,literals,selectmanycheckbox
For example: <h:selectManyCheckbox id="literalOptions" value="firstOption"> <f:selectItems value="[firstOption, secondOption, thirdOption]"/> </h:selectManyCheckbox> this doesn't work, but you get the idea? I want to pass literal (string-type) list options (not necessarily but possibly retrieved from a bean property as a String), the [a,b,c] list-syntax probably isn't correct, but which is? Or, alternatively, how...