Using ${} expression in JSP page

  • Thread starter Jean-Laurent Guillot
  • Start date
J

Jean-Laurent Guillot

I am using Tomcat 5.0.30 with struts 1.2, tiles and struts-layout 1.1

I want to write
${pageContext.request.contextPath}
in a page but the JSP parser does not replace by the web application context path

In fact, I do not kown how to use '${}' expression.

Do I have to use a particular module? If so, which?

Somebody can help me where to found documentation on this subject
 
E

Edwin Martin

Jean-Laurent Guillot said:
I am using Tomcat 5.0.30 with struts 1.2, tiles and struts-layout 1.1

I want to write
${pageContext.request.contextPath}
in a page but the JSP parser does not replace by the web application context path

In fact, I do not kown how to use '${}' expression.

Do I have to use a particular module? If so, which?

Somebody can help me where to found documentation on this subject

The online Struts documentation about "${} expressions" is very bad.

You must copy the *-el DTD's from the contrib-folder in the Struts
distrubution to your WEB-INF folder.

Dont's forget to add them to your web.xml file.

Edwin Martin
 
R

Ryan Stewart

Edwin Martin said:
The online Struts documentation about "${} expressions" is very bad.

You must copy the *-el DTD's from the contrib-folder in the Struts
distrubution to your WEB-INF folder.

Dont's forget to add them to your web.xml file.
You never have to either copy the TLDs (not DTDs) to WEB-INF or add mappings to
your deployment descriptor. The TLDs reside in the JAR file, and you can access
them by using their declared URIs, as per the JSP specification.
 
R

Ryan Stewart

Jean-Laurent Guillot said:
I am using Tomcat 5.0.30 with struts 1.2, tiles and struts-layout 1.1

I want to write
${pageContext.request.contextPath}
in a page but the JSP parser does not replace by the web application context
path

In fact, I do not kown how to use '${}' expression.

Do I have to use a particular module? If so, which?

Somebody can help me where to found documentation on this subject

If you mean JSP EL, you have to use a version 2.4 deployment descriptor
(web.xml), and then you can just put an expression like what you have above in a
page. e.g. ${5 + 5} would cause "10" to be printed to the output page. For
details on the JSP EL, see the JSP specification:
http://jcp.org/aboutJava/communityprocess/final/jsr152/

If you're talking about the struts-el library, you have to use the el tags
rather than the normal Struts tags. I think they're in the "contrib" directory
of the Struts distro. Their EL is the same as JSTL EL. You can find
documentation on that here:
http://www.jcp.org/aboutJava/communityprocess/final/jsr052/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top