Got it sorted - u were right Howard, had nothing to do with struts.jar. I added the path to the classes directory to the javac command and it compiled ok...not the way to go though! Thanks for all your help Angie >From: Howard Miller >Reply-To: "Struts Users Mailing List" >To: 'Struts Users Mailing List' >Subject: RE: Newbie to struts >Date: Tue, 17 Sep 2002 11:28:21 +0100 > >Correct me if I'm wrong, but it seems that the compiler is not finding >class >Book, which is (supposed to be) in the same default package as BookAction? >Therefore the problem has nothing to do with struts.jar. > >A couple of observations... >Don't use default packages with servlets and suchlike. You get away with it >for a while but then weird things start happening - I found out the hard >way!! >Strongly recommend looking at Tomcat/ant source setup. This has the >advantage of loading your application on-the-fly without creating subdirs >of >the tomcat distribution. >Are you using some sort of IDE for this (which might be screwing up the >classpath)? >Is BookActoin.java.. in your file list just a typing error, or is it really >called that? (That would do it!!) > >HM > >-----Original Message----- >From: angela mcgrenra [mailto:jj2angela@hotmail.com] >Sent: 17 September 2002 11:11 >To: struts-user@jakarta.apache.org >Subject: RE: Newbie to struts > > >OKAY > >I have a dir structure as follows > >C:\java\jakarta-tomcat-3.3.1\webapps\strutsShop\BookView.jsp >C:\java\jakarta-tomcat-3.3.1\webapps\strutsShop\CreateBook.jsp >C:\java\jakarta-tomcat-3.3.1\webapps\strutsShop\WEB-INF\classes\Book.java >C:\java\jakarta-tomcat-3.3.1\webapps\strutsShop\WEB-INF\classes\BookActoin.j >ava > >Code for BookView.jsp is: > ><%@ page language="java" %> > <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> > <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> > <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %> > > > > > > <bean:message key="index.title"/> > > > > Angela's test page > > Title:
> >
>
> > >Code for CreateBook.jsp is: > ><%@ page language="java" %> ><%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> ><%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> ><%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %> > > > > > <bean:message key="index.title"/> > > >

Create a book

> > > Title:
> >
> >
> >IN C:\java\jakarta-tomcat-3.3.1\webapps\strutsShop\WEB-INF\classes >I have Book.java (compiles into class file fine) >Code is : > >import java.util.Vector; > >public class Book >{ > > private String title = ""; > private Vector authors = new Vector(); > private int pages = 0; > > /** Standard constructor. */ > public Book() > { } > > /** @param title The new Title */ > public void setTitle(String title) > { this.title = title; } > > /** @return The title. */ > public String getTitle() > { return this.title; } > > /** @param pages The new number of pages. */ > public void setPages(int pages) > { this.pages = pages; } > > /** @return The number of pages. */ > public int getPages() > { return this.pages; } > > /** > We don't want to work with the Vector here, as it is > only a reference we would get! > @param author Add another author > */ > public void addAuthor(String author) > { this.authors.add(author); } > > > /** > Pay attention not to use the wrong number. > @param position The number of the author to remove. > */ > public void removeAuthor(int position) > { this.authors.remove(position); } > > /** @return The number of authors the book has. */ > public int getNumberOfAuthors() > { return this.authors.size(); } >} > >Code for BookAction.java is: > >import javax.servlet.http.*; >import org.apache.struts.action.*; > > > /* > The action for the creation of a book. > @author stephan@stephanwiesner.de > */ > public final class BookAction extends Action > { > > /** > @param mapping The ActionMapping used to select this instance > @param form The optional ActionForm bean for this request (if >any) > @param req The non-HTTP request we are processing > @param res The non-HTTP response we are creating > @return Return an ActionForward instance describing where and >how > control should be forwarded, or null if the response has >already > been completed. > */ > public ActionForward perform(ActionMapping mapping, > ActionForm form, HttpServletRequest req, > HttpServletResponse res) > { > System.out.println("Start perform(" + form + ") . . ." ); > String title = req.getParameter("title"); > Book book = new Book(); > book.setTitle( title ); > System.out.println("After creation of book: " + >book.getTitle() >); > > req.setAttribute("BOOK", book); > return mapping.findForward("bookCreated"); > } > } > >When I try to compile BookAction.java I get my error > > >BookAction.java:27: cannot resolve symbol > >symbol : class Book > >location : class BookAction > > Book book = new Book(); > >The problem seems to be that BookAction.java cant find struts.jar that I >have saved locally in my classes directory... > >I have saved this path into my CLASSPATH variable but to no avail... > > > > > >From: Howard Miller > >Reply-To: "Struts Users Mailing List" > >To: 'Struts Users Mailing List' > >Subject: RE: Newbie to struts > >Date: Tue, 17 Sep 2002 10:12:39 +0100 > > > >Hi, > > > >I've read this about 5 times now and still can't get my head aroud what >you > >are doing. > > > >Can you draw us a "picture" of what directories hold what, what your > >classpath is, and what your javac command is. > > > >Personally I have always used the structure recommended in the tomcat > >documentation that involves an ant build script, this gets around a lot >of > >classpath difficulties as it generates the path for you (and it could be > >quite lengthy with a STRUTS applicaton). > > > >Don't think that's your problem though. > > > >HM > > > >-----Original Message----- > >From: angela mcgrenra [mailto:jj2angela@hotmail.com] > >Sent: 17 September 2002 09:48 > >To: struts-user@jakarta.apache.org > >Subject: Newbie to struts > > > > > >Hi there > > > >I am working my way thtough a Struts tutorial and have a slight (simple >I'm > >sure) problem... > > > >I have a bean (Book.java)saved and compiled in my classes dir at > >"tomcat"\webapps\strutsShop\WEB_INF\classes > > > >In this folder also is BookAction.java which needs to be able to find >this > >bean, and a locally saved copy of the struts.jar file > > > >I have edited struts-config.xml and all other files are ready and waiting > >but my problem is when I try to compile the BookAction.java file in my > >classes dir. > > > >The error I get is > >BookAction.java:27: cannot resolve symbol > >symbol : class Book > >location : class BookAction > > Book book = new Book(); > > > > > > > > > > > >_________________________________________________________________ > >Chat with friends online, try MSN Messenger: http://messenger.msn.com > > > > > >-- > >To unsubscribe, e-mail: > > > >For additional commands, e-mail: > > > > > >-- > >To unsubscribe, e-mail: > > > >For additional commands, e-mail: > > > > > > >_________________________________________________________________ >Chat with friends online, try MSN Messenger: http://messenger.msn.com > > >-- >To unsubscribe, e-mail: > >For additional commands, e-mail: > > >-- >To unsubscribe, e-mail: > >For additional commands, e-mail: > _________________________________________________________________ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx -- To unsubscribe, e-mail: For additional commands, e-mail: