------=_NextPart_001_0001_01C173A1.5E7688C0
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Thanks nikhil. :)
----- Original Message -----
From: NIkhil Subhash Palshikar
Sent: 22 November 2001 17:32
To: Pro_JavaServer_Pages
Subject: [pro_jsp] Re: Newbie - Unable to access Inner Class of Java bean
from jsp
hi
the inner class should be refered as
artistBean.Consultant
that is
classname.innerclassname
nikhil
On Wed, 21 Nov 2001 Rudi Doku wrote :
> Hello,
>
> I tried your suggestions, and still no joy.
>
> I made the following changes:
>
> public static class Consultant {
>
> private static int key;
> private static String name =3D null;
>
> ........
>
>
> }
>
>
> I got the following error when i compiled my package
> and restarted tomcat.
>
>
> Generated servlet error:
> C:\jakarta-tomcat-4.0\work\localhost\_\artist\login$jsp.-
> java:111: Class tempArtist.Consultant not found.
> tempArtist.Consultant cslt =3D
> tempArtist.createConsultant();
>
>
>
>
> ----- Original Message -----
> From: NIkhil Subhash Palshikar
> Sent: 22 November 2001 02:57
> To: Pro_JavaServer_Pages
> Subject: [pro_jsp] Re: Newbie - Unable to access Inner
> Class of Java bean from jsp
>
>
> hi
>
> make the inner class static and try
>
> nikhil
>
> On Wed, 21 Nov 2001 Rudi Doku wrote :
> > Hello,
> >
> > I have a JavaBean with an inner class. I'm trying to
>
> > retrieve an object
> > from an ArrayList list (in a jsp page) and type cast
> is
> > as the inner class
> > of the java bean. I'm using tomcar ver 4 and get the
> > following error:
> >
> > org.apache.jasper.JasperException: Unable to compile
> > class for JSP
> >
> > This is the code in my jsp page --
> >
> > artistBean myArtist =3D new artistBean();
> > ArrayList artistList =3D myArtist.getArtistList();
> > Iterator artistListIterator =3D artistList.iterator()
> ;
> >
> > artistBean tempArtist =3D new artistBean();
> > tempArtist.Consultant cslt =3D
> > tempArtist.createConsultant();
> >
> > while(artistListIterator.hasNext()){
> > tempArtist.Consultant cslt =3D
> > tempArtist.createConsultant();
> > clst =3D (tempArtist.Consultant)
> > artistListIterator.next();
> >
> > ----------------------
> >
> > The JavaBean code is as follows:
> >
> > /*
> > * ArtistBean.java
> > *s
> > * Created on 21 November 2001, 02:33
> > */
> >
> > package com.doku.rudi;
> >
> > import java.beans.*;
> > import java.sql.*;
> > import java.util.ArrayList;
> >
> > /**
> > *
> > * @author administrator
> > * @version
> > */
> > public class artistBean implements
> java.io.Serializable
> > {
> >
> > // private static final String
> PROP_SAMPLE_PROPERTY
> > =3D "SampleProperty";
> > private final String PROP_USER_NAME =3D
> "FirstName";
> > private final String PROP_PASSWORD =3D "PassWord";
> > private final String artistSQLString =3D "SELECT
> > CsltKey, Name FROM
> > Cslt ORDER BY 2";
> >
> > //private String sampleProperty;
> >
> > private ArrayList artistList =3D null;
> > private Connection con =3D null;
> > private String password =3D "RD";
> > private PropertyChangeSupport propertySupport;
> > private Statement stmt =3D null;
> > private String userName =3D "Rudi Doku";
> >
> > public artistBean() {
> > propertySupport =3D new PropertyChangeSupport (
> > this );
> > artistList =3D new ArrayList();
> > }
> >
> > public void setConnection(Connection connection){
> > this.con =3D connection;
> > }
> >
> > public Connection getConnection(){
> > return this.con;
> > }
>
> >
> > public String getPassword () {
> > return this.password;
> > }
> >
> > public void setpassword (String password) {
> > String oldValue =3D this.password;
> > this.password =3D password;
> > propertySupport.firePropertyChange
> > (PROP_PASSWORD, oldValue,
> > password);
> > }
> >
> > public void setuserName(String userName){
> > String oldValue =3D this.userName;
> > this.userName =3D userName;
> > propertySupport.firePropertyChange
> > (PROP_USER_NAME, oldValue,
> > userName);
> >
> > }
> >
> >
> > public String getuserName(){
> > return this.userName;
> > }
> >
> >
> > public void setArtistList(ResultSet artistList){
>
> >
> > }
> >
> >
> > public ArrayList getArtistList() throws
> > java.lang.Exception,
> > SQLException {
> > if (artistList.size() =3D=3D 0) {
> > if (this.con !=3D null) {
> > try{
> > stmt =3D this.con.createStatement();
> > ResultSet rs =3D
> stmt.executeQuery(artistSQLSt-
> > ring);
> >
> > while (rs.next()){
> > int key =3D rs.getInt("CsltKey");
> > String name =3D rs.getString("Name");
> > Consultant myConsultant =3D
> > createConsultant();
> > myConsultant.key =3D key;
> > myConsultant.name =3D name;
> > artistList.add(myConsultant);
> > }
> >
> > }catch(SQLException e){
>
> > throw e;
> > }
> > }
> > else{
> > throw new java.lang.Exception("There is no
> > connection to the
> > database");
> > }
> > }
>
> > return artistList;
> > }
> >
> > public int getUserKey(String userName, String
> > password){
> > //DbConnection con =3D DbConnection.getInstance();
>
> >
> > return 1;
> > }
> >
> > public void addPropertyChangeListener
> > (PropertyChangeListener
> > listener) {
> > propertySupport.addPropertyChangeListener
> > (listener);
>
> > }
> >
> > public void removePropertyChangeListener
> > (PropertyChangeListener
> > listener) {
> > propertySupport.removePropertyChangeListener
> > (listener);
> > }
> >
> > public Consultant createConsultant(){
> > return this.new Consultant();
> > }
> >
> > public class Consultant {
> >
> > private int key;
> > private String name =3D null;
> >
> >
> > public Consultant() {
>
> > }
> >
> >
> > public Consultant(int key, String name){
> > this.key =3D key;
> > this.name =3D name;
> > }
> >
> > public int getKey(){
>
> > return key;
> > }
> >
> > public void setKey(int key){
> > this.key =3D key;
> > }
> >
> > public String getName(){
> > return this.name;
> > }
> >
> > public void setName(String name){
> > this.name =3D name;
> > }
> >
>
> >
> > }
> > }
> >
> > ---
> > Do you need true END-TO-END (e2e) Java Messaging (JMS)
> ?
> > Softwired
> > offers industry's ONLY complete 100% JMS messaging
> > solutions for your
> > needs TODAY.
> > Visit http://adtracking.wrox.com/track.asp?x=3Dp2p%2Fe%2-
> Fj-
> > ava%2Dsoftwired&url=3Dwww.softwired-inc.com NOW and find
>
> > out more!
> > Our unique product range includes: iBus//Mobile
>
> > (wireless data),
> > iBus//MessageBus (IP Multicast), iBus//MessageServer
> > (store and forward)
> > and much more!
> > niko77@r...
> > $subst('Email.Unsub')
> >
> >
>
>
>
> ---
> Do you need true END-TO-END (e2e) Java Messaging (JMS)?
> Softwired
> offers industry's ONLY complete 100% JMS messaging
> solutions for your
> needs TODAY.
> Visit http://adtracking.wrox.com/track.asp?x=3Dp2p%2Fe%2Fj-
> ava%2Dsoftwired&url=3Dwww.softwired-inc.com NOW and find
> out more!
> Our unique product range includes: iBus//Mobile
> (wireless data),
> iBus//MessageBus (IP Multicast), iBus//MessageServer
> (store and forward)
> and much more!
> rudidoku@h...
> $subst('Email.Unsub')Get more from the
> Web. FREE MSN Explorer download :
> http://explorer.msn.com
>
>
> ---
> Do you need true END-TO-END (e2e) Java Messaging (JMS)?
> Softwired
> offers industry's ONLY complete 100% JMS messaging
> solutions for your
> needs TODAY.
> Visit http://adtracking.wrox.com/track.asp?x=3Dp2p%2Fe%2Fj-
> ava%2Dsoftwired&url=3Dwww.softwired-inc.com NOW and find
> out more!
> Our unique product range includes: iBus//Mobile
> (wireless data),
> iBus//MessageBus (IP Multicast), iBus//MessageServer
> (store and forward)
> and much more!
> niko77@r...
> $subst('Email.Unsub')
>
>
---
Do you need true END-TO-END (e2e) Java Messaging (JMS)? Softwired
offers industry's ONLY complete 100% JMS messaging solutions for your
needs TODAY.
Visit http://adtracking.wrox.com/track.asp?x=3Dp2p%2Fe%2Fjava%2Dsoftwired
&url=3Dwww.softwired-inc.com NOW and find
out more!
Our unique product range includes: iBus//Mobile (wireless data),
iBus//MessageBus (IP Multicast), iBus//MessageServer (store and forward)
and much more!
To unsubscribe send a blank email to $subst('Email.Unsub')Ge
t more from the Web. FREE MSN Explorer download : http://explorer.msn.co
m