Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > JSP cannot find my JavaBean

JSP cannot find my JavaBean
Thread Tools
Registered User
Join Date: Feb 2003
Status: Offline
Reply With Quote
Mar 6, 2003, 12:37 AM
 
Hi

I am leanring JSP, and am playing with Beans. I have this bit of code:

<jsp:useBean id="Data" class="DataBean" scope="request" />

But I get this error:

/Library/Tomcat/work/Standalone/localhost/depolitic/datainput_jsp.java:49: cannot resolve symbol
symbol : class DataBean
location: class org.apache.jsp.datainput_jsp
DataBean Data = null;


My bean in Located in my /WEB-INF/classes/

Why cannot it find the bean? Do I have to make an entry into the web.xml file?
     
Senior User
Join Date: Oct 2000
Location: Lawrence, KS
Status: Offline
Reply With Quote
Mar 11, 2003, 11:30 AM
 
A few things you may want to look into are:

1. Put the bean in a package i.e. The first line of your code should be something like:

package SomeDirName.bean;

This could be a required -but I'm not 100% sure... To get this to work, you have to create the dir SomeDirName. Place your bean code in it. Change directory to the one that contains SomeDirName. Then, you must then execute javac with the relative path your bean code. Something like:

javac -d ./SomeDirName/DataBean.java

Your JSP code should look like:

<jsp:useBean id="Data" class="SomeDirName.DataBean" scope="request" />


2. Carefull with the scope attribute. Should it be session instead of request?


And the answer is no, you need not declare the bean in your web.xml.

Hope it helps!


     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 08:51 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2