jstl

JSTL c:forEach causes @ViewScoped bean to invoke @PostConstruct on every request

Hello, Again i see that the @PostConstruct is firing every time even though no binding attribute is used. See this code :- <?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; <html xmlns="http://www.w3.org/1999/xhtml" x...

Problem with JSTL and weblogic

I get the following error when I run my java ee app on weblogic, javax.servlet.jsp.el.ELException: Cannot find PropertyDescriptor for 'name' for bean 'class java.lang.String' I want to print a list of artists with the following class, public class Artist { private int id; private String name; private String genr...

Loop through a Map with JSTL

I'm looking to have JSTL loop through a Map and output the value of the key and it's value. For example I have a Map which can have any number of entries, i'd like to loop through this map using JSTL and output both the key and it's value. I know how to access the value using the key, ${myMap['keystring']}, but how do I access the key?...

How to display formated Calendar type in JSTL?

I am using Calendar type in Java and I would like to display formated date in JSTL. I was trying: <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> <fmt:parseDate var="date" type="date" dateStyle="short" value="${photo.dateCreated}" /> <c:out value="$...

What causes a lexical analysis error for eclipse in jsp EL validation?

I've got some EL code inside of a JSP tag. The line starts as follows: <c:if test="${pageContext.request.serverName eq \'localhost\'}"> Eclipse throws up an error on this, saying: Unable to analyze EL expression due to lexical analysis error I'm unsure what this even means. Is this an eclipse bug? Am I mixing EL and the JSTL tag...

Eclipse javascript character encoding

Hi, I'd like to display some language specific characters from javascript but I can't. My app is a Java webapp and the front end is jQuery. All the characters that are sended from the server - in a JSP or with AJAX - are displayed properly. When I want to display some text hardcoded in to the javascript file it's broken. I'm using Ecl...

value from resource bundle as pattern in formatDate

I want to read pattern for JST formatDate also from resource bundle but this naive approach does not working, what I'm doing wrong ? in com/company/MyPortlet.properties is this key: company.date.format = yyyy-MM-dd HH:mm:ss In page I have: <fmt:setBundle basename="com.company.MyPortlet"/> <fmt:formatDate value="${date}" pattern="$...

How to convert an arbitrary object to String with EL + JSTL? (calling toString())

Is there any way to call toString() on an object with the EL and JSTL? (I need the String representation of an enum as index in a map in a JSP EL expression.) I hoped something like ${''+object} would work like in java, but EL isn't that nice, and there does not seem to be any function that does it. Clarification: I have a variable some...

show notification in jsp page depending on a flag?

I have HTML code in the jsp page that I want it to be displayed only after the user submits data and get redirected to this page. So I have to set a success flag as a parameter in the link like: http://site.com/page?success=true Not sending in the request because it will be lost since I am redirecting I don't want to send it in the li...

Java: how to debug an invalid JSTL declaration?

I've seen this kind of issue on SO (and on the Net overall) quite a few times. For example here: http://stackoverflow.com/questions/1884529 Earlier today I was trying on a JSP (regular .jsp, not .jspx) to do this, because I stupidly cut/pasted some example found on the net: <%@ taglib prefix = "c" uri = "http://java.sun.com/jstl/core...

Populate JSP dropdown with database info

I'm looking for the way to populate a JSP dropdown. I want that when the JSP loads it fills the dropdown with the info that I have in a database table. I'm including the code of my class that will create the array and fill it with the database info. What I don't know is how to call that class from my JSP and fill the dropdown. // this ...

Assigning outcome of another JSTL tag as value of one JSTL tag

I've got this, which is working: <c:choose> <c:when test="${sometest}"> Hello, world! </c:when> <c:otherwise> <fmt:message key="${page.title}" /> </c:otherwise> </c:choose> And I want to change it to this: <c:choose> <c:when test="${sometest}"> <c:set var="somevar" scope="page" value="Hello...

How to prevent auto correction / suggestion of text in textarea?

We provide a page where a student can provide his answer to a certain question. This information is obtained via an input text area box and we would prefer that the browser doesn't auto correct and indicate grammatical errors on the student responses (e.g. obey is correct but obay is wrong). The browser shows a red underline if there are...

Displaying data from database in a jsp

hi, in order to display the query result in a jsp; in my servlet i do the followwing: try { s= HibernateUtil.currentSession(); tx=s.beginTransaction(); Query query = s.createQuery("select opcemployees.Nom,opcemployees.Prenom,dailytimesheet.TrackingDate,dailytimesheet.Activity," + "dailytimeshee...

Unable to pass attribute from controller to view

I'm using Spring MVC 3 for a web app. In the app a URI template is supposed to be handled by a controller method, which then passes an attribute to a view. Currently, the controller does handle the request, and it even forwards to the correct view. However, it does NOT pass the attribute to the view. Below are the URI template, controlle...

Set request attributes when a Form is POSTed

Is there any way to set request attributes (not parameters) when a form is posted? The problem I am trying to solve is: I have a JSP page displaying some data in a couple of dropdown lists. When the form is posted, my Controller servlet processes this request (based on the parameters set/specified in the form) and redirects to the same ...

Testing if a User is Logged in Via JSP/Spring-MVC

Using Spring 3 MVC and JSP, I simply want to test if a user is logged in, I'm not interested in using Spring Security currently <jsp:useBean id="myAppUser" type="com.xxx.MyUser" beanName="myUser" scope="session" /> <c:choose> <c:when test="myUser.loggedIn"> //dostuff </c:when> <c:otherwise> //dootherstuff ...

JSTL - Using forEach to iterate over a user-defined class

What methods do I need to add to a custom Java class so that I can iterate over the items in one of its members? I couldn't find any specifications about how the JSTL forEach tag actually works so I'm not sure how to implement this. For example, if I made a generic "ProjectSet" class and I woud like to use the following markup in the JS...

JSTL XML Transforms not working with nested XSL includes

I have a bit of JSP that does this: <c:import url="/xsl/Transformer.xsl" var="xslt" /> <x:transform doc="${actionBean.dom}" xslt="${xslt}" xsltSystemId="/xsl/"> This transforms the XML exactly as expected so long as Transformer.xsl contains no <xsl:include> tags or so long as any documents it does include do not include anything. Ho...

How can I replace true and false with yes or no using JSP and JSTL?

How can I replace true and false with yes or no using JSP and JSTL? i hava values TRUE and FALSE in my table. i want when i retive these values using jstl on my jsp pages the true false will replace with YES AND NO ...