File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes JSP Bean reference Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP Bean reference" Watch "JSP Bean reference" New topic
Author

JSP Bean reference

Rob Symth
Ranch Hand

Joined: Apr 29, 2011
Posts: 32
Hello Folks,
I have a bean which is loaded into a servlet as below

<jsp:useBean id="sanityBean" class="com.ibm.lotus.apollo.sanity.SanityBean" scope="application"/>
<jsp:setProperty name="sanityBean" property="*"/>


The bean is then referenced further down the jsp as below

<input type="text" name="emails" size="20" value="${sanityBean.emails}"/>

However what gets displayed on the input box is exactly ${sanityBean.emails} i.e it does not get resolved, as this is a legacy application I cannot change the code, on Webspahere 7.1 this works as expected just when deployed onto Tomcat this issue occurs, any ideas out there?

Thanks for your help
Rob
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60058
    
  65

How is the web.xml declared? Using the 2.4 or 2.5 XML Schema? Or the 2.3 DTD?

The latter will disable the EL in JSP pages.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60058
    
  65

P.S. Why is this bean being loaded into application scope?
Rob Symth
Ranch Hand

Joined: Apr 29, 2011
Posts: 32
web.xml snippet below


<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60058
    
  65

OK, next step. Create a JSP that contains nothing but ${3+4}

What is displayed?
Rob Symth
Ranch Hand

Joined: Apr 29, 2011
Posts: 32
I think I found the issue, I am using Tomcat 5.5 which only support servlet 2.4, the app itself is defined as 2.5, see below

Tomcat 5.5 is Servlet 2.4/JSP 2.0, so #1 can be scratched. You didn't change anything in webapp before deploying I assume, so #3 and #4 can likely be scratched. Now left #2. Maybe you declared it as Servlet 2.5 for Tomcat 6.0 while the Tomcat 5.5 only understands up to with Servlet 2.4. This way everything will become a mess as Tomcat would then fallback to least compatibility modus. You need to redeclare web.xml as Servlet 2.4 so that it will work in both Tomcat 5.5 and 6.0. The declaration should look like:
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60058
    
  65

Rob Symth wrote: the app itself is defined as 2.5

Not according to what you have posted so far.
Rob Symth
Ranch Hand

Joined: Apr 29, 2011
Posts: 32
I think I got mixed up, what I had before was the web.xml for Tomcat itself
The web.xml for the app is below


<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60058
    
  65

Please AvoidRedHerrings.

Well, yeah. If you're using Tomcat 5, you need to declare the web.xml appropriately and build against the correct versions of the Servlet and JSP APIs.
 
Consider Paul's rocket mass heater.
 
subject: JSP Bean reference
 
Similar Threads
Servlet strange?
Plz help..how to make a bean class
Page Cannot Be Displayed
upload an avatar or other file
usebean getProperty and setProperty in the same form field