Head First book & Tomcat setup

I am currently reading Head First Servlets & JSP. In the first chapter it gives you a sample servlet to run(Ch1Servlet.java). It tells you to setup a directory OUTSIDE of /tomcat.
/Project1
/Project1/src
/Project1/classes
/Project1/etc
On my computer it is setup as C:/Java/Project1
Then it tells you to compile it from the command line like this:
javac -classpath /your path/tomcat/common/lib/servlet-api.jar -d classes src/Ch1Servlet.java
Here is what I used
javac -classpath /Program Files/Apache Software Foundation/Tomcat 5.5/common/lib/servlet-api.jar -d classes src/Ch1Servlet.java
This causes an error
javac usage invalid: Files/Apache
I am guessing this is because there are spaces in the classpath name. I copied the servlet-api.jar to the C:/Java folder and it compiled successfully. Without having to copy files to other folders how can I get around this error?
Once you get it compiled it tells you to add the class files to the WEB-INF/classes directory and add the web.xml to the WEB-INF/etc directory. The book didn't explain where this directory is. I only imagined it being on its own in the Tomcat5.5 directory but it wasn't there. I looked under webapps and there is not a WEB-INF directory. What is the book trying to tell me?
It also tells me once Tomcat is started to type in http://localhost:8080/ch1/Serv1. Under the web.xml file the mapping url is set to /Serv1 but the other description in servlet mapping is Chapter 1 Servlet. I don't see where the ch1 directory is. Can anyone help me with this?
My system OS: Windows XP
It also didn't explain why you would setup a directory outside of tomcat and then have to deploy your compiled classes back into tomcat. I am fairly new to Java and brand new to JSP. This part of the book seems to assume I know all this. Can anyone put me in the right direction?

I am currently reading Head First Servlets & JSP. In
the first chapter it gives you a sample servlet to
run(Ch1Servlet.java). It tells you to setup a
directory OUTSIDE of /tomcat.
/Project1
/Project1/src
/Project1/classes
/Project1/etc
On my computer it is setup as C:/Java/Project1
Then it tells you to compile it from the command line
like this:
javac -classpath /your
path/tomcat/common/lib/servlet-api.jar -d classes
src/Ch1Servlet.java
Here is what I used
javac -classpath /Program Files/Apache Software
Foundation/Tomcat 5.5/common/lib/servlet-api.jar -d
classes src/Ch1Servlet.java
This causes an error
javac usage invalid: Files/Apache
I am guessing this is because there are spaces in the
classpath name. I copied the servlet-api.jar to the
C:/Java folder and it compiled successfully. Without
having to copy files to other folders how can I get
around this error?
Add double quotes around your class path (e.g. javac -classpath "c: /Program Files/Apache Software Foundation/Tomcat 5.5/common/lib/servlet-api.jar ")
Foundation/Tomcat 5.5/common/lib/servlet-api.jar -d
classes src/Ch1Servlet.java
Once you get it compiled it tells you to add the
class files to the WEB-INF/classes directory and add
the web.xml to the WEB-INF/etc directory. The book
didn't explain where this directory is. I only
imagined it being on its own in the Tomcat5.5
directory but it wasn't there. I looked under webapps
and there is not a WEB-INF directory. What is the
book trying to tell me?
You want to create a directory called ch1 under tomcat's webapps directory.
Under the ch1 directory create a WEB-INF directory. And under WEB-INF create a
classes directory.
It also tells me once Tomcat is started to type in
http://localhost:8080/ch1/Serv1. Under the web.xml
file the mapping url is set to /Serv1 but the other
description in servlet mapping is Chapter 1 Servlet.
I don't see where the ch1 directory is. Can anyone
help me with this?
The url-pattern in the web.xml is what is used to access your servlet.
Chapter1 Servlet is just a way to map from the servlet-class to the url-pattern.
If you read further in the book all this will be explained.
My system OS: Windows XP
It also didn't explain why you would setup a
directory outside of tomcat and then have to deploy
your compiled classes back into tomcat. I am fairly
new to Java and brand new to JSP. This part of the
book seems to assume I know all this. Can anyone put
me in the right direction?You want your source to be outside of tomcat. Once you have compiled everything,
you then deploy to your container. Hope this helps

Similar Messages

  • Head  first jsp

    hello
    i need this book as a soft copy :
    head first jsp & servlet.
    thanx

    To avoid having to use the classpath over and over add it to your system environment variables:
    Right click 'My Computer' > Properties > Advanced > Environment Variables
    Under 'System Variables' if you don't already have have a 'CLASSPATH', create one. If you do, append the path to your servlet-api.jar ( e.g. c:\Tomcat\common\lib\servlet-api.jar ). Remember, different entries into the classpath must be separated by semi-colons (;).
    Save and open a fresh console window ( the changes don't reflect in consoles that were already open ).
    Of course, you should still learn how to work with the classpath variable: http://java.sun.com/j2se/1.4.2/docs/tooldocs/solaris/classpath.html
    This is what your command should be:
    javac -classpath c:\Tomcat\common\lib\servlet-api.jar -d classes src/Ch1Servlet.java

  • Head First Java

    I'm looking for a good book to learn Java with. Head First Java seems to be fairly good by the Amazon reviews, but I was wondering if anyone who's read it could answer a few questions.
    1. Would it be any good for someone good at other programming language
    2. How advanced does it get?
    3. Does it teach fairly good application design?

    1. The book is intended for people who have a basic understanding of programming, so knowledge of other programming languages will be an advantage.
    2. It covers quite a few basics of programming in Java, including some GUI development, Sockets, and Threads.
    3. It steps you through building some applications that incorporate good design techniques. It's not intended as a discourse on application design, but it provides some good fundamentals.
    In my opinion, it's a fantastic book and a very entertaining read.

  • I have downloaded several books into ibooks.  Started reading one and closed it when I was done reading for the day.  Now I want to access other books and when I open ibooks it goes directly to that first book.  What can I do? Help please.

    I have downloaded several books into ibooks.  Started reading one and closed it when I was done reading for the day.  Now I want to access other books and when I open ibooks it goes directly to that first book.  It does not give me the shelf to choose what book I want to read - goes directly to the first book. What can I do? Help please.

    There should be a Library button on the top left. If not ap the middle of the screen to get it to appear.

  • Problems creating my first book in iphoto

    I'm just getting started with my first book - of my children's easter holiday. I'm having a few problems...
    1. I have typed text onto the bottom of some pages but when I print or preview, you can't see the text.
    2. Is there any way to alter the layout of the text - eg to centre it at the bottom of the page? I can only work out how to left and right align.
    3. Every time I want to print out a page or to preview it, the whole book has to be assembled again - this takes ages! Am I doing something wrong.
    4. I've read a couple of the other discussions and there are warnings about how you crop your photos and making them in the ration 4:3. Am I being naiive, but don't you get a book that looks like the thing you see in front of you? Doesn't lining up the photo in the 'frame' mean that the photo is cropped like that? (I'm using the large softcover crayon template)
    I'd be very grateful for any tips from anyone with more experience as I don't have time to go through all the other messages (3 children under age 5 you see!)
    Helen

    Welcome to the Apple Discussions.
    1 - Have you changed the font in the Setting pane for any of the text boxes? One possible reason you don't see the text is that you have more text in the box than it's designed to hold. Do you have any yellow triangles in the text boxes? What page layout are you using, one, two, three...?
    2 - Right now there's no way to center text. If it's just one line you can add some spaces at the beginning to sort of center it.
    3 - Unfortunately that's how iPhoto works. Do a Print to PDF and then you can preview the pdf file outside of iPhoto and print only those pages you want to check out.
    4 - The reason for the suggested crop is that the frames on the pages are in that ratio. If your image is a different size ratio it will not fill the frame are completely or it will fill it in the smaller size and cut off some in the longer dimension if you try to snap it to the frame. Cropping beforehand just insures that you'll be able to get the entire image in the frame at the maximum size possible.

  • When I plug my device into the computer for the first time the setup process doesn't begin. What do I do?

    When I plug my device into the computer for the first time the setup process doesn't begin. What do I do?

    Try to connect in recovery mode, explained in this article:
    iOS: Unable to update or restore
    Before that, back up your device, explained here:
    iOS: Back up and restore your iOS device with iCloud or iTunes
    How to back up your data and set up as a new device
    You can check your warranty status here:
    https://selfsolve.apple.com/agreementWarrantyDynamic.do

  • My first book

    I am starting my first book and iPhoto has a row of pictures at the top but it doesn't have all my pictures.  How do I get it to put all or maybe change to another event along the top bar?

    Try drag/drop from the album/event your wish to use.
    And/or select 'Photos' bottom right, then choose your source in 'Show:' top right.

  • Two ipads/One Apple ID - don't want second to see first books and emails. Suggestions?

    Two ipads/One Apple ID - don't want second to see first books and emails. Suggestions?

    If you don't want them to have access to the same books and other purchased media, they would need to be signed into a different Apple ID in Settings>iTunes & App Store.  If you don't want them to see the same iCloud email, they would need to be signed into different iCloud accounts with different IDs, or have Mail turned off on one of them in Settings>iCloud.  If you want to migrate one of them to a different iCloud account to accomplish this, reply back and I'll explain how to do this.

  • I downloaded my first book on iBooks and says its downloaded but its not there

    I downloaded my first book on iBooks and it says its downloaded but its not in my library.

    Did you check on the device you downloaded it on?  Did you actually purchase and download the book on your iPad?  If so, did you check in the iBooks app?  If you downloaded the book on iTunes, did you sync your iPad using iTunes and then check the iBooks app?
    You did purchase the iBook at the Apple iBook Store, right?

  • Available first book about SpeedGrade, writing for Alexis Van Hurkman

    Hi.
    Already available the first book about SpeedGrade on Amazon: http://t.co/f0ckZAJs
    At the moment only in Kindle version. I hope soon in paper.

    About time! Thanks for sharing. Will be helpfull for my trainings.

  • I use podcasts all the time but downloaded my first books from the istore this morning. how do I get them to my ipod?

    I use podcasts all the time but downloaded my first books from the istore this morning, I can't get them synced onto my ipod. What am I doing wrong?

    the audiobooks I purchased show up in itunes under books and under purchased items but i cannot make them sync to my ipod. I followed your directions but it did not help. I have drag and dropped to a playlist which shows up on itunes but not on my ipod even after repeated syncs. when I try to drag and drop to the books or audiobooks in the itunes list it gives me the NO symbol.

  • First time sync setup - Firefox 5.0 - nothing happening

    First time sync setup - Firefox 5.0 - When I click on "Create a new account," nothing happens. How can I fix this? Thanks.

    Try downloading Firefox again, then uninstall Firefox, remove the program directory, and install it all over again.

  • Slow name completion on any but first book in selected list

    Just upgraded WA App (web) piece to HP3. All other agents, etc. on HP2. This was done because we're having WA agent connectivity issues (known issue apparently), plus we run BES and RIM has not tested HP3 yet (so they say).
    Anyway... prior to HP3 patching, we had to type first name (space) and then first initial for name to complete. This seems to have been corrected in HP3, as I now can down arrow through list after typing part of first name.
    Problem is, while it quickly searches/lists whatever happens to be in the first book in search order, the other books take 30-60 seconds to 'wake up' so I can scroll through.
    Any way to correct/speed up?
    thanks

    Lindsey,
    It appears that in the past few days you have not received a response to your
    posting. That concerns us, and has triggered this automated reply.
    Has your problem been resolved? If not, you might try one of the following options:
    - Visit http://support.novell.com and search the knowledgebase and/or check all
    the other self support options and support programs available.
    - You could also try posting your message again. Make sure it is posted in the
    correct newsgroup. (http://forums.novell.com)
    Be sure to read the forum FAQ about what to expect in the way of responses:
    http://forums.novell.com/faq.php
    If this is a reply to a duplicate posting, please ignore and accept our apologies
    and rest assured we will issue a stern reprimand to our posting bot.
    Good luck!
    Your Novell Product Support Forums Team
    http://forums.novell.com/

  • Ordered First Books

    I ordered my first large hardcover books. The seemed to be printed in one day and shipped the next. I'm very interested in seeing the quality. I have scanned the threads and can't see too much feedback on quality. As soon as I get mine I'll post my thoughts. One odd thing occurred with the second order. It got canceled for some reason. I didn't do it but for some reason the folks at Apple seemed to think it wasn't worth printing perhaps they are right but i think i should be the judge of that... I just reordered it and this time it seems to have stuck.
    Lawrence
    http://www.lwsphoto.com
    g5 Qaud   Mac OS X (10.4.3)  

    I second your opinion on the professional quality of the Aperture books.
    I use them for sample books for clients to browse, just to get ideas and see samples. While I do offer the Aperture books, I don't push them. I rather see them purchase a professional quality book from Asuka Books.
    For real professional quaility books look at Asuka Books. They are very stunning. You create each page layout in CS2 with their templates. The books are significantly more expensive than the cheapo Aperture ones, but inline with other professional level providers of flush albums and books.
    The range of sizes, aspect ratios, materials, and binding options allow you to get creative with what you can offer as final output to your clients.
    To see a price list you must apply for membership. You receive your first book at half price.. use this for a sample book.
    Asuka takes 4-6 weeks to complete the books as well.
    BTW, I do not work for Asuka Books... I am waiting for my sample book

  • HT4059 I have purchased my first book through iBooks and downloaded it onto my iPad but cannot figure how to start reading it as it won't open! How do I get to page 1?

    Anyone know how to open a book on an iPad? Just bought my first book through iBooks but cannot open it!

    Sleep/Wake button
    http://i1224.photobucket.com/albums/ee374/Diavonex/Album%201A/1afe952dffcdd516d9 2babf54fe4553b.jpg

Maybe you are looking for

  • SAP and SQL Reporting Services.

    Hi, I'm trying to implement a few reports using MS SQL Reporting Services.  I don't think that SAP (we are currently on 4.6C, and BW is not an option for now) has anything nearly as cool.  The problem is that SQL RS can only create queries against OD

  • Passing of ResultSet to Stored Procedure(Oracle 8i)  from Java

    My requirement is such that I want to send a resultset to a stored procedure(In oracle8i). Through Java API's. The input parameter to the PLSQL is a ref cursor. I am trying to send the resultSet using CallableStatement of java but it is throwing an I

  • Compiling inner classes

    Hi, I have an applet with inner classes (the applet is contained in a single .java file). When I compile the applet, a number of *$*.class files are created for the inner classes. However, a friend of mine compiles the same .java file and he gets a s

  • Macbook Air Capacity showing Problem

    Hey! I'm having a problem with my MacBook Air 13" 2013 (128GB). When I go to finder, it shows that I have 37.02GB of available storage. But after calculating what's in Macintosh HD, I figured out that I had 49.17GB of free storage. But when I went to

  • FORALL and UPDATE

    hello, I have a problem with forall command. I need update database 'A' with data from database 'B'. I wrote this code: DECLARE TYPE Typ1 IS TABLE OF VARCHAR(255) index by binary_integer; replace_what Typ1; TYPE Typ2 IS TABLE OF ROWID index by binary