expression 1 « Development « JSP-Servlet Q&A

1. How comment a JSP expression?

How can I comment a JSP expression like: <%= map.size() %> Is there something like <%= // map.size() %>?

2. Using Regular Expressions in JSP EL

In EL expressions, used in a jsp page, strings are taken literally. For example, in the following code snippet

<c:when test="${myvar == 'prefix.*'}">
test does not evaluate to true if the value ...

3. el expression in jsp:invoke

I'm trying to use the following snippet inside my tag file:

<%@ attribute name="content" fragment="true"%>
<c:set var="part" value="content"/>
<jsp:invoke fragment="${part}" var="partValue"/>
and compiler gives me the following error:
Syntax error, insert ") Statement" to complete IfStatement
so ...

4. JSP: EL expression is not evaluated

I have a JSP page running on Tomcat 5.5. I have the following code:

 <c:forEach var="i" begin="1" end="10" step="1">
  <c:out value="${i}" />
  <br />
The output I am getting is:
${i} ...

5. El expression doubt

in EL expression in JSP we can use ${"1"+"2"} but not ${"Dark"+"Knight"}. Why?

6. TeamCity: Scripting elements jsp:declaration, jsp:expression, jsp:scriptlet are disallowed here

I am not sure where to begin with this error message. I have tried googling, but I was never able to nail down a solid reason why I am getting this ...

7. Expression language equivalent

what will be corresponding expression language statement for request.getRemoteUser() ?

8. JSP EL (Expression Language) causing problems in Eclipse

My system: Ubuntu 9.10. Eclipse 3.5.1 with Java EE 1.2.1 (manual install - NOT from synaptic). Web Developer Tools 3.1.1 I've recently adopted someone else's code (a Dynamic Web Project), and run ...

9. Expression language for IP address

what is the corressponding expression for getting ip adress of server, as ${pageContext.request.serverName} is for getting the server name

10. Expression Language in jsp not working

Hi I am new to jsp and using Expression language.I am using Eclipse Galileo with version 2.5 and tomcat6 server . I just want to ask that my simple expression language ...

11. Why do we need out implicit object in JSP When we are supposed to use expressions?

I am studying JSP. I have a doubt. When we use the Expressions in JSP, then why do we need out implicit object in JSP? Can anybody explain on this. Thanks

12. Unusual error while using Expression language in JSP only for particular king of properties- Check this

I have this unusual scenario: I have a registrationVO with few properties and getter setters for that. For example city or bCity with their getter methods getCity() and getBCity() In JSP i tried to ...

13. param : implicit EL (Expression Language) object in JSP

What if I have URL like: servlet.jsp?myparam=myvalue These 2 ELs should return output "myvalue" , but I actually don't understand why?:


14. ELResolver to escape all string output of expression

I have an existing web application to which i need to add protection against script attacks. For this i need to escape string before displaying on pages. One approach is a ...

15. jsp:include not working with Expression Language (JSP version 2.5, EL enabled)

I've read: but it's slightly different. Using EL for referencing file works fine like the one below.

   <link rel="stylesheet" type="text/css" 
However when try to use JSP include tag with ...

16. Dealing with Java Expression Language on a page

I am working on the frontend of a project that gives me Java Expression Language tags to work with. In one instance I need to see if it is returning an ...

17. JSP expressions do not evaluate with Jetty

I've spent over a day trying to figure this out, I have looked at the related questions and tried to IRC with the guys at Jetty but to no avail. We moved ...

18. How to HTML-encode in the JSP expression language?

Consider the following piece of JSP:

<param name="FlashVars" value="${flashVars}" />
The value of ${flashVars} contains ampersands and needs to be encoded before it is output. Instead, JSP expects the value of ${flashVars} to ...

19. Accessing Java Bean Properties by Expression Language

I have some Java beans that I am trying to use in a JSP:

class Review{
    int id;
    String text;
    User author;

20. Mixing expressions and expression language (<%= %> inside of c:if)

I need to access some constants in my jsp, and sadly the EL does not offer any functionality for it. There are some options like the unstandard tag library, but I'd like ...

21. Difference between Java Expressions and Java Scriplets in JSP

I find myself needing to learn a little bit of JSP for my Software Engineering class. One of our homework questions is as follows:

What are the output of these two code ...

22. Are JSP expressions evaluated inside HTML comments of a JSP page?

Are JSP expressions evaluated inside HTML comments of a JSP page? i.e What would server output in this case?

Jeremy <%="Flowers"%>
Will the expression be resolved or will it remain as an expression ...

23. How to do not evaluate a jsp expression?

I have a jsp expression for an attribute of a tag: service="${service}" and I don't want the ${service} to be evaluated. How can I do that? Cheers, Daniel

24. Can JSP expression language be used for Portlet environment?

I know a few Portals and I've never seen any usage of jsp expression language in any of them. Does it have a reason ? Because it seems, that there are ...

25. Issue with Expressions when debugging JSP pages

I'm using eclipse 3.6.1 and WTP 3.2.3 on centOS 5.5. I have this issue where my expression values are showing up as blank when stepping through a jsp page (see screenshot)

26. EL expressions are not evaluated in JBoss AS 4.2.2

EL expressions are not evaluated in JBoss AS 4.2.2. I have web.xml declared conform the Servlet 2.4 spec.

<web-app id="WebApp_ID" version="2.4" xmlns="" 

27. JSP Expression Language on Jackson's JsonNode

Let's say I'm using Spring and have a controller that returns a model containing a field data that is an instance of Jackson's ObjectNode. Within data I have a ...

28. Expression language, don't show variable value

I am pretty new in Java EE, i am trying use that .war file , but it seems index.jsp file doesn't show variable, I see only ${} ...

29. Calendar object in Expression language

How do i get day, month and year (and every Calendar.XXXXXXX value) in expression language?


30. JSP error escape quotes in expression

I need to check type to display correct message like:

${row.type} <c:if test="${row.stype ==\"Note\" }">Important Note</c:if>
But the problem that escaping produce strange error: Unable to analyze EL expression due to ...

31. Why this regular expression shows safety?

I have a JSP redemption for XSS attacks, in which it checks if the content matches a regular expression to determine whether it is safe or not, here is the code:

String ...

32. How to get the value in an EnumMap using a key in EL expression?

I have a EnumMap:

EnumMap<Gender, Integer> genderMap = new EnumMap(Gender.class);
where Gender is public enum Gender {Male, Female}; And I have req.setAttribute("genderMap", genderMap); Now I want to get the value from genderMap by a ...

33. JSP: using expressions as values to tablib attributes

i am tring to create my own taglib, and pass a jsp variable to the taglib, as an attribute value. <%@ taglib uri="/WEB-INF/taglib.tld" prefix="custom"%>

<%String myFilter =....; %>
<custom:printAllPeople filter="<%=myFilter%>" >

the tld:

34. EL expressions in Apache tile definition is not processed

I am using Apache tiles for templating and part of the template is a header text. This text depends on the section the page belongs to. Each page contains a bean ...

35. JSP and Adding Strings returned by JSP Expression Scriptlet

I am having script errors of "Error expected ')'" in IE when attempting to do the following:

alert(<%=SystemConfig.getTranslatedTextByKey(LBIBOConstants.LANG_KEY_MODIFYTIME_ALRTMISSINGA, userLocale)%> + strMessageString + <%=SystemConfig.getTranslatedTextByKey(LBIBOConstants.LANG_KEY_MODIFYTIME_ALRTMISSINGB, userLocale)%>);
I would originally like to just alert with one ...

36. Comparing string and boolean in Expression language

I have this behaviour I do not really understand

${requestScope.rs_redirectFacade == 'error'}
  1. How can it be exlpained?
  2. What it the correct way to write the test in order ...

37. Debugging JSP expression ?

Using NB 6.5.1 and Tomcat. I 've set breakpoint to an expression with method call <%=class.method()%> and can't get into the method. Am I using this right or issue with my ...

38. How to use debugger to display JSP Expression Language (EL) values

I am using Netbeans 6.71. and I have a JSP page that I call as follows: /myproject/index.jsp?action=list In my jsp page I would like to see the value of by moving ...

39. JSP expression in a JavaScript

40. Text box value attribute & javascript expressions

I am having a problem with the Text Box's value= attribute and the usage of a javascript expression to prime it. Here's a sample JSP that illustrates the problem: testJSP.jsp <% String stringField = "Hello There!"; %> <%=stringField%> Input Text Box:

42. Using a "less than" symbol in an expression .....

This is not a JSP issue at all; if you do a "view source" of the page you are sending to the browser, you will see that all the string is there. The problem is that "<" is a reserved markup character and is confusing the browser. As you have discovered, the proper way to emit a reserved character on an ...

43. Expression Language in Taglibs

44. Expression Language

45. JSP 2.0 Expression Language

46. JSP expression

If I have a statment like

48. expression language

49. How do I escape a literal unicode expression?

"\u003E" --> "&" "\\u003E" --> "u003E" "\\" --> "\" "\\" + "\\u003E" --> "\u003E" Using entities is easier. public class AsciiUnicodeFilter { public static String doFilter(String s) { return s.replaceAll("<", "<") .replaceAll(">", ">") .replaceAll("\"", """) .replaceAll("&", "&") ; } public static void main(String args[]) { StringBuffer sampleDoc = new StringBuffer(""); sampleDoc.append("\n") .append("\t") .append("Food & Drinks -- \"Healthy?\"") .append("\n") .append("\n") .append("\n"); System.out.println("Before: ...

50. JSP 2.0 Expression Language

51. Scriptlet and Expression!!!

55. XML syntax for JSP expressions

56. Expression Language

Hi Hans, How detail will be discussed in the appendix? When I come across SCWCD 1.4 exam, many questions are related to EL. Some of them even give us one goal (for example): I want to print out the number 42, and then give us 6-7 options on EL. I think many syntax of EL can archive the same goal, however, ...

58. Weird Expression Langauge Behavior

Not weird at all when you consider that the JSTL has no char type. So both 'Y' and "Y" denote a string with a single character. Refer to section JSP.2.3.2 in the JSP 2.0 Specification. (If you are writing JSPs and don't have a copy of the Specification handy, you're doing it wrong).

59. JSP2.0 Expression Language web.xml setting

I'm using JSP2.0 EL with tomcat 5 version. Also I made the following change in web.xml. But EL is not working. I tried with both global web.xml (conf/web.xml) and local web.xml (webapps/ROOT/web.xml), but EL is not working. Should I do any more changes in my web.xml? Pl help. web.xml ------- Also included the following directive ...

60. Expression Language does not work

61. JSP directive attribute from expression

62. EL test expressions

63. Not parsed expression

64. EL expressions are not being evaluated

65. Expression Language

66. EL expression evaluation

67. EL expressions . vs [ ]

hello all, iam a newbie to EL plz help me ,if we have a code some thing like this class Person{ Dog dog; setter and getter methods for dog object } class Dog{ Toy toy; setter and getter methods for toy object } and finally Toy class with a name property i know we can toy name using //ofcourse person ...

68. Expression Not Being Evaluated

69. Expression Language

70. EL expression..[ ] operator

72. JSP Expression

Here is my Jsp source. <%! String text="Welcome to Expression language"; %> Welcome to the jsp programming.
If you see this page, it means jsp are also funtioning properly. Text = ${text} When I deploy this jsp on tomcat server. For some reason expression ${text} is not replaced with the text Instead I am just seeing ...

73. EL expression evaluation

Hi folks! I'm invoking my servlet through link = http://localhost:8080/ . servlet adds an attribute "duck" of class Duck (JavaBean with "name" property) to request scope. Then I forward a request to test.jsp page. What I want to do is evaluate parameter to EL expression. I know that I could do this by spliting evalparam parameter to two parts ...

74. EL expression evaluation

75. Expressions problem

76. how to write an El expression

77. El Expression problem

78. Expression Language Doubt

80. el expressions and escaping Javascript strings

Hi all, I use some el expressions to generate some client-side javascript as follows: ${user.lastName} The problem is that some users' last names contain single quotes (e.g. O'Reilly), so I'll need to escape them with \'. Is there any way to do this with el / jstl, so ...

81. Nested JSP Expressions not working

Sorry about the smilies, and thanks for the reply. It explains why the code didn't work either. So how do you get around this??? This particular case, the tag generates the name of a framework template, which varies depending on the template currently being used. How else can I assign this value? That's why I tried the tag, ...

83. Expression Language not working

Hello everyone, I am trying to print the value ${2+5} or similar in JSP, but it's not working and result shows just the same "${2+5}. How can I get the desired result. Is there some configuration I missing at. Please help. Thanks & Regards, Varun Narang. [ March 08, 2006: Message edited] Sorry for not including the version information with the ...

84. annoying expression

85. Expression and EL

Originally posted by Ed Ward: I don't think it has to be a scoped attribute. It could just as well be a JSP variable of that name declared using the variable directive and set in a tag file (or a tld for a tag using the element)? Within the tag file a call to ${something} would then return the value ...

87. illegal start of expression

88. evaluate dynamic expression language

89. using el expressions in Jsp

90. regarding expression language

91. Expression Language

92. How to use Expression Language(EL)?

93. c:forEach and runtime "end" expression

In the following jsp snippet, I'm trying to use the length of an array to set the limit. The reason, as can be seen from the body of the

94. JSP Expression Language question

97. Trouble using JSP expression inside a custom action attribute

Thanks for observing that <%! %> is non-thread safe ... you seem to be very concerned about that fact. Can you help me understand why I should care about thread safety for a variable whose value I don't plan to update (only read)? I don't see how there's a race condition that I should be concerned about?

98. expression language

100. JSP Expression question

Hi All, I have a simple JSP Expression question <%=" MY NAME IS JOHN "; > The above tag prints MY NAME IS JOHN. It deletes the leading and trailing spaces and the spaces between two words as well. In my case i used following tag <%= fun();> fun() is a function that returns dynamic data say for e.g " MY ...