Results 1 to 2 of 2
  1. #1
    Join Date
    May 2014
    Posts
    3
    Rep Power
    0

    Default Netbeans won't parse Expression Language in a JSP page

    Hi, i've this code

    PHP Code:
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@page import="Javabean.Articolo"%>
    <%@page import="java.util.ArrayList"%>
    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    
    <!DOCTYPE html>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>JSP Page</title>
        </head>
        <body>
       
             <%
           
              String nome="porcodio";
              %>
             
              <div> ${nome}</div>
             
        </body>
    </html>
    I'm using Netbeans with glassfish server 4. When i try to launche the web page, i see that "nome" is not printed... Why?
    My older projects that uses EL, still works fine, while this wont' parse the syntax... why??

  2. #2
    sehudson's Avatar
    sehudson is offline Senior Member
    Join Date
    Mar 2010
    Posts
    364
    Rep Power
    5

    Default Re: Netbeans won't parse Expression Language in a JSP page

    Expression Langauge is used to evaluate scoped variables (page,request,session,attribute). The variable that you have declared is simply a local variable.
    To get this to work, you would need to store the nome variable as a request attribute:

    Java Code:
             <%        
              String nome="porcodio";
              request.setAttribute("nome", nome);
              %>
    Then, you can use Expression Language to access it, as you have.

    You really don't need to use EL here, just use a scripting-language-expression:

    Java Code:
             <% String nome="porcodio"; %>
             <div><%=nome%></div>
    Last edited by sehudson; 06-03-2014 at 07:05 PM.

Similar Threads

  1. How do you parse an inputted expression?
    By Propinquity in forum New To Java
    Replies: 1
    Last Post: 11-19-2013, 03:49 PM
  2. Replies: 0
    Last Post: 02-01-2012, 04:50 PM
  3. How to parse an expression with given format
    By mariaK in forum New To Java
    Replies: 2
    Last Post: 11-23-2011, 12:17 PM
  4. Replies: 2
    Last Post: 07-18-2011, 08:11 AM
  5. Multiple Language in my web page
    By Albert in forum JavaServer Pages (JSP) and JSTL
    Replies: 3
    Last Post: 09-21-2009, 02:46 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •