variable « JSTL « JSP-Servlet Q&A

JSP-Servlet Q&A
JSP-Servlet Q&A » JSTL » variable 
I am including this jsp into another jsp which parent jsp. value of (note.notesText) is displaying the html conetns like as follows;

1. Why do I get an AbstractMethodError when setting a JSTL variable?

I am trying to set a variable that I will refer to in a custom JSP tag, so I have something like this in my JSP:

<%@ taglib prefix="c" uri="" %>
<c:set var="path" ...

2. Assigning values from JavaScript to Java variable

How to assign a value from JavaScript to Java variable in the JSP page? Is it possible to do this? The following is the javascript function:

function loadGroupMembers(beanArrayVal){


3. Overwriting variables in JSP/JSTL

I have the following code:

<c:forEach items="${mergeList}" var="sublist" varStatus="index">
                <c:forEach items="${sublist}" var="item" varStatus="row">
So my intention is to ...

4. how to pass javascript variable to the jstl code

I have something like the below code. I need to pass the variable selectedIndex to the JSTL code. How can I do this?

function updateSP(selectedIndex)
    <c:if test="${entry.key eq IC.oList[selectedIndex]}">

5. Which variables can be accessed with the ${...} syntax in a Struts tag in a JSP page?

I'm getting a little bit frustrated since I can't find out which variables I can access with the ${...} syntax in a Struts tag, placed in a JSP page. As an example ...

6. How to set the JSTL variable value in javascript?

How to set the JSTL variable value in java script?


 function function1()


  var val1 = document.getElementById('userName').value;

  <c:set var="user" value=""/>  // how do i set val1 here? ...

7. How do I assign hidden value to JSTL variable?

How do I assign hidden value to JSTL variable? Example:

<input type="hidden" name="userName" value="Administrator" />
<c:set var="user" value="" />  // How do I set hidden variable value (Administrator) here?

8. using javascript variable inside jstl

I want to iterate a HashMap in javascript using jstl. is it possible to do like this?

function checkSelection(group,tvalue){

<c:forEach items="${configuredGroupMap}" var="groupMap">
    alert("aa<c:out value="${groupMap.key}"/>");
    <c:if test="${groupMap.key==group}">

9. How do I pass Javascript variable to and JSTL?

How do I pass Javascript variable to and JSTL?


    var name = "john";  

    <jsp:setProperty name="emp" property="firstName" value=" "/>   // How ...

10. How to access variable set by JSTL core in my JSP page?

In my webapp, I want to set a default cookie to store a locale of 'en_US'. I have functionality in place for the user to change this successfully. However, I've removed a ...

11. jstl tags do not link with jsp variables

ím trying to add jstl/jsp component to a spring+flex+hibernate project. Im using Tomcat 5, downloaded and added the jakarta-taglibs-standard-1.1.2 dependencies, made some changes to the web.xml, etc... dont want to get ...

12. JSTL forEach use variable in javacode

I want to use the actual item from my c:forEach in a <% JavaCode/JSPCode %>. How do I access to this item?

<c:forEach var="item" items="${list}">
   <% MyProduct p = (MyProduct) ${item}; ...

13. How do you minify/obfuscate JavaScript code in a JSP that has JSP/JSTL variables mixed into it?


var x = <c:out value="${x}"/>
<c:if test="${empty doExternal}">
I want to minify/obfuscate JavaScript contained in a large JSP file in which numerous JSP/JSTL variables are mixed into the JavaScript code such as in ...

14. How to retrieve a request scoped variable using JSTL on Struts 1

I'm refactoring some legacy code that uses Struts 1 (No flames please), and I am having a difficult time retrieving a parameter I set in my Action class. Here is the ...

15. How to cast JSTL variable to string in Liferay JSP?

I habe a problem with my latest Liferay Portlet or rather a JSP I'm using in this portlet. I am using a string array that contains strings which are shown on the ...

16. Assign fmt:formatDate output to a c:set variable

I want to do something like this:

<c:set var="strDate" value="<fmt:formatDate value='${obj.dateIn}' pattern='ddMMyyyy'/>"/>
to obtain the date as (formatted) string and assign it to a variable for later use but it isn't working, any ...

17. Passing value of a java method to a javascript variable using Struts 2 tag

I have a JSP file

<%@ taglib prefix="s" uri="/struts-tags"%>
<% response.setContentType("application/javascript"); %>

var collegename = '<s:text name="student.collegename"/>';
student.collegename defined in file. now i can use collegename variable in java script file. Is there any tag in ...

18. Access one tag's variable in another

I have a custom tag

<%@ tag body-content="scriptless"%>

MyClass mc = request.getAttribute("someValue");
Now I want to access this mc value in another tag. The above tag surrounds, this other tag. For example,
<custom:aboveTag> ...

19. EL ExpressionFactory, scopes, JSTL forEach tag, iterated variable: where is?

I am working with ExpressionFactory inside my program, and I wan to make ValueExpressions and variables be accessible from JSP with EL expressions. I can't understand something: looks like my variables I ...

20. JSTL variables not working

I wrote the following code:

        int accountNumber = Integer.parseInt(request.getParameter("accountNumber"));
        int depositAmount = Integer.parseInt(request.getParameter("depositAmount"));

21. Query regarding JSP variable access

Forgive my ignorance, I am stuck with this. What I need to do is, access a date member in my bean and pass it to a method defined, something like below ...

22. how to assign javascript variables to jsp or jstl

Can anybody tell me how to assign javascript variables to jsp request or to jsp session. I am doing something like this Here deletedRows is a hidden field.

var del=45;
<%String del_values = request.getParameter("deletedRows");%>
<%request.getSession().setAttribute("del_rows", del_values);%>
I ...

23. Using variables in jstl if statement

I have something like this

 <c:forEach var="authority" items="#{SPRING_SECURITY_CONTEXT.authentication.principal.authorities}">

      <c:if test="${fn:contains( ${authority} , ROLE_ADMIN) }">

but it does not working, any ...

24. JSP, JSTL. Problem with variables and methods

I have some problem with using jstl. I have this:

<jsp:useBean id="view" class="user.View"></jsp:useBean>
<jsp:useBean id="user" class="user.Validation" scope="session"></jsp:useBean>

<c:if test="${user.getValid() == 0}">
<c:out value="${view.printUserData(user)}"></c:out>
and View class looks:
package user;

import java.lang.StringBuilder;

public class View {
    public ...

25. Check if variable exists in JSTL

I've got a PersistenceSet and would like to check if it contains a certain variable. How can I check in the JSTL whether subitem exists or not? However when I try to access ...

26. How to use a variable data as a scope variable in jstl

I want to dynamically create variable names in java el. The problem is that the second line returns sessionScope.saved_activity as a string instead of data.

<c:set var="savedKey" value="sessionScope.saved_${entry.key}" />

<td> <input type="text" ...

27. When is it appropriate to set a request-scoped variable in a JSP?

In my experience, it is rarely/never necessary to set scope="request" on an EL variable. For example, I have a page that, given an item parameter, constructs a URL specific to that item ...

28. [Tiles 2 Standalone] Where are my JSTL/EL variables?

I'm having a look at Tiles and I'm having a few problems getting it to work with my JSTL. The templating works fine and I see the page structure I expect. The trouble is that none of my JSTL/EL variables are complied. If I just try putting a variable straight to the page, it'll just print it out as is (e.g. ...

29. How to declare and use variables in JSTL ?

Hi For lot of simpler calculations and validations using Javascript we used to declare variables and then do them and use it in Javascript before submitting a form. Say, int x=2,y=3;x=x+y; and use it in the form as a default value and then we may validate the user input from Javascript and then post the form date using Javascript itself. For ...

30. JSTL: EL and variable names with "."

33. using JSTL variable in java code of JSP

34. Using JSTL variables in a Javascript?

Hi, all! Correct. JavaScript is executed on the client-side. But that doesn't mean that JSTL can't be evaluated and mixed with JavaScript. Not only can you pass JSTL evaluated code to JavaScript function, you can add JSTL code within the tags. I was caught by surprise when I could do this and set the proper window size. Here is a ...

36. Dynamic variable name in JSTL

37. Convert JSTL variable type

38. Variables from JSTL to JSP

39. problem with page variables in JSTL

40. questions about JSTL variables

// now want to access this "msg" variable in JSp, how ? Questions 1. Session Object "NameList" includes a List of Names Strings, so I want to iterate through it, and concatnate its name String with a comma separator, and eventually the msg should ...

41. usage of substring in jstl variable

43. JSTL 1.1 - Get value from method of an Obj and set it to a variable

How can I get the value from the method of an Object (e.g., length of a String by calling myString.length()) and set the value of the length to a variable? In the code below, my objective is to set myVar with the length() value obtained from myString of myForm object. Code is somewhat like: ...

44. Processing dynamic variable in JSTL

45. Resetting an objects variable with JSTL and EL

Using JSP 2.0 and JSTL 1.1.2 I have an object defined within ${sessionScope.sessionData} This sessionData object has a getter and setter for a variable of another object. While I can access the getter like this ${sessionScope.sessionData.myVar} I am not sure how to set/reset it I have tried both ${sessionScope.sessionData.var["null"]} and Both does not give any error, but ...

46. jstl variable handling

The need to do this is usually an indicator that JSTL isn't being used properly. JSTL is meant for scriptless JSPs where all of the heavy lifting is done with Java objects before context is ever forwarded to the JSP for markup. If you were comparing objects, you could simply bind your scriptlet variable to request scope with request.setAttribute("name", value) and ...

48. Using JSTL/EL to access page variable

50. Decalring a int variable and using it in for loop in JSTL or EL

Hi, I would like to declare a int variable and use it as the looping variable. Just like this for(int i=0; i<10; i++) { // do something } I want to do this in a JSP. I can do it in scriplet. But I dont want to use a scriplet and want the do it using either a JSTL () or ...

51. Session Variable and JSTL

52. How to get Browser Variable value in side JSTL

Hi All, A little problem am facing. I done know how I will get a users entered username and password from the form in browser and put the value in JSTL tag. I have tried quite a fre but got invalid datasource errors. Please help me get out of this. My code is like below:

53. Access static variables using JSTL

55. Dynamic variable name in JSTL

59. How do I set this variable in JSTL?

60. A JSTL doubt while assigning a variable using

Hi All , Im trying to use a scoped variable in my jsp to help with formatting of the code .However, I think Im doing something wrong at two points , however cant figure out what exactly im doing wrong. // Point 1 ...

62. Need to display the jsp variable(String) into html?

Hi, I am having the following line in notes.jsp.

But, i want that table and hyperlink should be display in the screen. If i copy the contents and replace in the place of "

63. Setting a variable in JSTL for use in a JSP function

Hi, I need to call a function in JSP that takes a parameter to get the content of an EBase form field. The parameter is defined by a field in a database. I am getting the data back using JSTL but I need a way of embedding the database field value into the JSP function call. Here's the code: Java Code: ...

64. How pass variable from jsp to servelet

65. Using JSTL to capture HTTP referer data and serialize into a variable

Using JSTL, how I can both capture the 'referer' data, strip it down to just wwwdotsomedomaindotcom, and then declare it as a variable for later equality/inequality comparisons? And I had to write out the dummy domain name above because this message board still prevents me from posing URLs or images until I hit 20 posts. Thanks in advance.

66. how to access JSP variable in javascript

68. Problem with showing a variable in jsp with

Hi everybody as u might know i'm one more newbie with one more problem. The thing is, i'm doing a simple shopping cart and i can't show the results of my bussines logic. I use Interceptors, Struts 2, Hibernate and Jsp tech to do this. Here is my code: books.jsp