Is Java enough for a programming language?
Java is widely used especially for server-side applications. Other languages have their place and professionals should know more than one.
I am trying to create tables in my database using the Create.java program on the CD, but I am getting an 
exception "cannot modify the design of the table customer. It is in a read-only database". I am able to create 
tables directly using SQl but the program doesn't work. Why?
You can only create the database once. Before running the Create program you should delete Sales.mdb or rename it.
Regarding the Java IDE for our projects, what is the best choice for CECS471?
Two possible options on Windows XP:
1. J# .NET
2. netbeans 4.1 (SUN open-source)
Or is there a better operating system and/or IDE option?
J# is limited to very early versions of Java. Netbeans is fine. The most popular is Eclipse which is freely available from eclipse.org.
I am using jdk1.5 and here it doesn't recognise "Color". Everytime I use it like graphics.setColor(Color.red)
 or Color c=new Color(255,0,0) it gives me an error at C of Color. Error "cannot find symbol is given.Why?
You need to import the java.awt package using the statement import java.awt.*;
how to pass data from the class contructor to main method?
Use an instance variable declared outside of any method. The the constructor and the other methods will be able to access it.
Regarding project #1. Are we supposed to write a program that can read, write, and display images? Or we are supposed to 
create an image using the format given and write a program that can simply read and display it?
You need to write the file representing the image of four horizontal stripes. Either the same or another program must read and display any image of this format.
Why is it that when I am drawing on the frame there is a certain lapse of time when the first line is drawn and then the 
second line is drawn?
I can't tell without seeing the code. Normally it should display instantly.
I have opened the file http://www.cecs.csulb.edu/~art/471/image and saved in my computer. When I read it and output 
the bytes I get: 255 255 128 128 200 192 192 40 30 and the rest are 3's and 2's. So it's seems that the file does not follow the 
format specified for the project since we need 12 bytes for the 4 colors and two for the width and height, right? Was that 
intentional? Am I doing something wrong?
Internet Explorer removes the zeros. Use the file image.exe where I trick IE into thinking it is executable.
Can you give us some help about how to display the image? Do I extend my class to a frame? Applet? how do i communicate 
with paint method to draw according to the size and color read from file? Can you provide a pseudo-code? 
Extend Frame not Applet. Use a WindowAdapter to handle the window closing event. Read the file in the constructor, but use instance variables declared outside any method so that they will be available in paint.
I use "try" and "catch" in the main, and get this error message  "test.java:196: exception java.io.IOException is never 
thrown in body of corresponding try statement catch(IOException e)" when I compile.  I do not understand why, so could you help me?
The code that you put in the try-catch does not throw IOException. You only need to use try-catch when you create a file or read from a file or perform another file operation. If you get that error, just omit the try-catch.
On Project#1 I am having difficulty outputting the results to the frame.  I can generate the frame, and all the files and 
data, but I cannot figure out how to put the Line(x1,y1,x1,y1) onto the frame environment.   What method do we use to write pixels 
to the frame?  Do we need to use Swing?  Is there an example of how this is done?  I see there are some classes developed in the 
Computing with Java book (p.411, Line.java, Shape.java), but it is not clear how these are used in conjunction with the frame.  How
 are pixels put onto the frame?  Do I need to use the draw(g) method...is g the frame or is g the line?  or is there some other 
method we are supposed to develop on our own?
Draw inside the method public void paint(Graphics g). Use g.drawLine(x,y,x,y) where (x,y) is the pixel. You do not need Swing. Applet examples can be used as a model, but use the constructor rather than the init method. The drawing is the same.
How do i run a java file i wrote in notepad?
Open a console window. Change to the directory containing the program. Execute the command javac progname.java to compile and the command java progname to run. Add any command-line arguments after the progname.
Do we have to write a server which listens to port 110 for Project #2?
No, just a client.
should we use com.sun.mail.pop3 package for doing the project #2?
No, it is not necessary.
Using what should the user interface be created for Prj #2?
You might use a List the list the message senders and subjects and a TextArea to display the selected message.
For Project #2, should we parse out the headers and other MIME information?
It would look nicer if you did, but it's up to you.
How to stop the connection from getting aborted automatically in POP3?
It shouldn't abort unless it doesn't accept your password. If it accepts your password it should accept commands until you quit. You need to use a POP3 server for which you have an account.
How to append data into a text area line by line instead of just on the right side of the alreay present text?
Add a "\n" wherever you want a new line.
Why do I get this error?

E:\cecs471\MailClientApplet>appletviewer MailClientApplet.html
java.security.AccessControlException: access denied (java.net.SocketPermission [
popmail.cecs.csulb.edu:110] resolve)
        at java.security.AccessControlContext.checkPermission(AccessControlConte
xt.java:264)
        at java.security.AccessController.checkPermission(AccessController.java:
427)
        at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
        at java.lang.SecurityManager.checkConnect(SecurityManager.java:1031)
        at java.net.InetAddress.getAllByName0(InetAddress.java:1117)
        at java.net.InetAddress.getAllByName0(InetAddress.java:1098)
        at java.net.InetAddress.getAllByName(InetAddress.java:1061)
        at java.net.InetAddress.getByName(InetAddress.java:958)
        at java.net.InetSocketAddress.(InetSocketAddress.java:124)
        at java.net.Socket.(Socket.java:178)
        at MailClientApplet.init(MailClientApplet.java:29)
        at sun.applet.AppletPanel.run(AppletPanel.java:374)
        at java.lang.Thread.run(Thread.java:595)
This is a security violation because an applet can only connect to the machine from which it was downloaded. Use a standalone application instead.
I am having trouble when I try to retrive the text for a message. I used the following while loop but it doesn't ever end: 
          while((s=fromServer.readLine()) != ".")
Is there something wrong with this?
Use the equals method to test string equality. The != operator tests reference identity which is not what you want.
For Project #3 do we create and populate the DB as you did in your programs and then write another program to do all the 
other operations?
You could, or you could create the database in Access by entering data directly..
I get this error when I run your Create.java program, any idea why?  I havn't modified it at all.
I followed all of the steps that you layed out in the book.
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in CREATE TABLE statement.
        at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6958)
        at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7115)
        at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:3111)
        at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:338)
        at sun.jdbc.odbc.JdbcOdbcStatement.executeUpdate(JdbcOdbcStatement.java:288)
        at Create.main(Create.java:21)
The syntax of the CREATE statement has an error. Check that it follows the same pattern as in my examples. It could be a type name that is incorrect.
Is it enough to create two table for proj #3?
Yes as long as you include queries that use both tables in the same query.
I have created a SportsAlmanac database using Access 2000 on my home computer.  I then modified the URL in Example 3.1 Connect.java.  I put Connect.java and compiled Connect.class in the same directory as the SportsAlmanac.  When I run with various URL's, but also with " String url = "jdbc:odbc:SportsAlmanac"; "
I always get an error:

C:\java\Proj3>java Connect
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
        at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6958)
        at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7115)
        at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.java:3074)
        at sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOdbcConnection.java:323)
        at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:174)
        at java.sql.DriverManager.getConnection(DriverManager.java:525)
        at java.sql.DriverManager.getConnection(DriverManager.java:171)
        at Connect.main(Connect.java:19)

You have to register the database as an ODBC source. Follow the instructions in the text.
I tried to setAutoCommit to false right before two insert statements and I got this error:
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]Attribute canno
 be set now
        at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6958)
        at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7115)
        at sun.jdbc.odbc.JdbcOdbc.SQLSetConnectOption(JdbcOdbc.java:5115)
        at sun.jdbc.odbc.JdbcOdbcConnection.setAutoCommit(JdbcOdbcConnection.ja
a:651)
        at Records.actionPerformed(Records.java:286)
        at java.awt.Button.processActionEvent(Button.java:388)
        at java.awt.Button.processEvent(Button.java:356)
        at java.awt.Component.dispatchEventImpl(Component.java:3955)
        at java.awt.Component.dispatchEvent(Component.java:3803)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
        at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchT
read.java:234)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThr
ad.java:163)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157

        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149

        at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
You need to set auto commit to false right after you create the connection.
When we download tomcat http://jakarta.apache.org/site/downloads/ from this 
site what are all the file we have to download? And when downloaded where do we place our class files to access using 
http://localhost:8080/servlet/filename?
You could download either version 4 or version 5. I used 4.1.31 on my laptop. Download either the .zip or the .exe version for Windows. The revision of Chapter 4 on my web site shows where to put the files when using Tomcat.
what should be the address of the classpath?
That depends on what classes you need. For servlets you need servlet.jar which is available using either Tomcat or JRun.
when I am trying to compile my servlet it says javax.servlet deos not exist. what should I do?
That means that servlet.jar is not on your classpath.
what do we download other than jdk and tomcat to get javax packages?
Nothing else for servlets and JSP.
when I use javac -classpath c:\jsdk2.1\servlet.jar file.java the file compiles and when I used 
-classpath %catalina_home%\common\lib\servlet.jar file.java it gives me errors HttpServer not found and so on. 
In the environment var. catalina home has been set to the dir of tomcat. What should I do?
Add .; as a prefix to the other classpath directory. This includes the current directory in the classpath. Check that servlet.jar is in the directory you list on the classpath. If not search for it and put that directory in the classpath.
My html files are in webapps\ROOT\ and my servlet files are in webapps\ROOT\WEB-INF\classes.  When I submit a html form, 
the web server can not find the servlet file.  Do I have to configure anything in webapps\ROOT\WEB-INF\web.xml ?
The action is the web form must have the correct relative URL. From what you say that is probably /servlet/filename.
I got an error when I compiled the ShoppingServlet.java:
ShoppingSerlvet.java:5:package shopping does not exist.
I have ShoppingServlet.java in C:\Tomcat\webapps\examples\WEB-INF\classes
and CD.java in C:\Tomcat\webapps\examples\WEB-INF\classes\shopping
The .class files must be in these folders. You have to compile the .java files.
I placed my package containing the bean in %catalina_home%webapps\examples\web-inf\classes\packP. my jsp files in 
%catalina_home%\webapps\examples\jsp. But when I compile my .java files it says package not found. where should I place the 
package containing the Bean?
Your placement is not the problem it is the classpath. Compile with the classpath option as .;%catalina_home%\webapps\examples\web-inf\classes.
I installed and configured Tomcat 4.1.31. Now web apps work fine, but when I try to run my previously created stand alone 
applications  
java classname 
I got the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: classname
What may be wrong? Do I need to make any additional changes in env variables?
You either have to run from the folder containing the .class file or set the classpath to include the path the that .class file.
What is the link to "Music Without Borders" example? 
Understanding JavaServer Pages Model 2 Architecture
When I compile servlet it gives me the following what does that mean?
C:\j2sdk1.4.2_05\bin>javac -CLASSPATH %CATALINA_HOME%\common\lib\servlet.jar GetOrder.java

javac: invalid flag: -CLASSPATH
Usage: javac  
where possible options include:
  -g                        Generate all debugging info
  -g:none                   Generate no debugging info
  -g:{lines,vars,source}    Generate only some debugging info
  -nowarn                   Generate no warnings
  -verbose                  Output messages about what the compiler is doing
  -deprecation              Output source locations where deprecated APIs are us
ed
  -classpath          Specify where to find user class files
  -sourcepath         Specify where to find input source files
  -bootclasspath      Override location of bootstrap class files
  -extdirs            Override location of installed extensions
  -d             Specify where to place generated class files
  -encoding       Specify character encoding used by source files
  -source          Provide source compatibility with specified release
  -target          Generate class files for specific VM version
  -help                     Print a synopsis of standard options
if i change -CLASSPATH to -classpath in above compilation its giving
javac :invalid flag:Files\Apache
Try javac -classpath .;%CATALINA_HOME%\common\lib\servlet.jar GetOrder.java and be sure that you have set CATALINA_HOME.
How can I substitute java.awt.List in html? I would like to allow multiple selection.
Use the select element as in my PostOrder example but add the attribute multiple="multiple" to allow multiple selections.
I'm using j2sdk1.4.2_04. I've set all of the env. variables as in "Running.txt" for Tomcat 4.1.31.  I've even changed 
the default port to 1977. However I still can't get the "Welcome.html" to work.  Any ideas?
If Tomcat is running when you try http://localhost:8080/ or :1977 if you changed the port, then you need to put Welcome.class 
and Welcome.html in the folders I indicate in the revised Chapter 4.
I can start tomact and that's about it
< b>
How and where do I set Catalina_Home?
At a command prompt just execute SET Catalina_home=path_to Jakarta_Tomcat. To make it permanent you can set an environment variable using Contol Panel, System.
why does it say NoClassDefFoundError when I am trying to run my Proj #3 's database creating java program. I already used 
it and did my proj #3.
It cannot find the .class file for the class named. Either from from the directory where it is located or use the -claspath flag.
For the Login portion of project 4:
1) How do you prefer this is done?  Via server auth, Database verification, or other?
2) How do you prefer that this is handled for other pages (i.e. to prevent users that are not logged in from gaining access), or 
does it not matter as long as a user that is not logged in cannot get to the other pages?
1. Compare the password with a database entry. 2. Users must login to see the other pages. Go to an error page the way the music store example does.
C:\>javac -classpath %CATALINA_HOME%\common\lib\servlet.jar Welcome.java
javac: invalid flag: ûclasspath
Usage: javac  
Get rid of the character preceding "classpath"
For the search and update page, can we have a single text input box that allows the user to type the query string to be 
executed??? Like the example Sales.html (Figure 4.15) in the book.
The user should not have to know SQL. The user should make choices in an HTML form like project 3 but with a web form instead of AWT or Swing components.
Requirements for Project 4 state "...servlet will dispatch to a search and update page if the login is successful."   
What are the different operations required of the Project 4 database tool?  For Project 3 the user could do 4 operations with the 
sports database: add, remove, change, search.  The question restated is, are we expected to implement all 4 sports database 
operations (add,remove,change,search) for Project 4?  One interpretation is that all Project 4 requires is the user be able to 
perform 2 operations: change, search. 
I assume the database part would be the same as project 3 which is already completed. The only difference is that the data for the query comes from an HTML form rather than AWT or Swing components. So there not need to be any changes to the database part. Use the Model 2 architecture in which the servlet is the contoller and the JSPs are the views.
For project 5, the first XML tag that I recieve from the server response is:

However, I find that I cannot translate the response at all if the URL is in that tag.  (for example, if I put the response
in a file, then take that part out, it works).  What gives?
XSLT shouldn't care what attributes you have in the tag. I have no idea why that happens. Also I'm not quite sure what you mean by "cannot translate."
The output of java -cp . MakeXml is:
[customers: null]
I created the database and datasource properly (I'm using them in other applications). 
Maybe it has something to do with Tomcat installation? Right after the installation I wasn't able to run any of the java programs. 
On my other machine (Windows 98, no Tomcat) I created the same database and datasource and the program produces correct output.
Why?
Leave off the classpath option. It is restricting you to the current directory.
Besides the SubscriptionID, do we need an Associate Tag??? If so, how do we get one? Are we supposed to use ECS 4.0 or AWS 
3.0???
You do not need an Associate Tag. It is for business associates. Use 4.0.
Whenever I use your code plus a similar xsl (,,) sheet to transform the XML, the program 
consistently spits out everything in the XML, minus the tags.  Do you know what I am doing wrong, or do you need me to paste more?
Sounds like your xsl has a problem. I would need to see it.
How to make a reference to the title element in a style sheet (xsl file), so later user will be able to click on the title 
and see the reviews?
First use xsl to find the titles and make the list. When the user chooses a title then check the TotalReviews tag for the number of reviews and find each review in a Review tag. Do all this after you have matched the selected title, so the reviews will relate to that title.
Should we write the result of search (xml format) to file, then read it and transform to 
html using xsl like in xmlToHtml.java example? Or, maybe there is a better way to do it?
You could do that, or as you read it you good store it in memory.
Xml search result contains an attribute (namespace) xmlns

which causes some problem. The statement   doesn't return any value. However when I manually remove 
xmlns atrribute, it works just fine and I got all the title. What changes do I need to make in xsl file to make it work without 
removing the attribute?
The Title is nested. You might try selecting each level, Items, Item, etc. until you can directly see the Title.
I also am having problems when the root tag is:
<ItemSearchResponse xmlns="http://webservices.amazon.com/AWSECommerceService/2005-07-26">
However, when I remove xmlns="http://webservices.amazon.com/AWSECommerceService/2005-07-26">  so that it is just <
ItemSearchResponse>
I get no errors. I can then easily get to any nested tag within the document.
I have re-read chapter 13 several times now and I cannot find a solution. (Other than inserting Java code that removes the xmlns 
attribute) - but I know this is not the best way.
I haven't encountered that. I'll have to try it. Meanwhile delete it manually.
Since xsl files are static, how can we pass an attribute specifying a selected book to xsl file so it produces html of 
reviews of only that book?
You could do another search for that book, or you could chec all the titles in the initial response for the one that matches the user's selection.
I could not find a link on amazon.com to register the services.  Could you show me? Thanks.
Register
Do you want the Customer reviews and/or the Editorial Reviews?
Customer
Why do I get extra information in the output from the XSLT?
The default is to display the body of a tag, so if you do not want the default you can include an empty template which will match a tag and do nothing, as I do with the age tag in titles.xsl.
when i click the selected title(which is a link),how to get the value of that link(i.e selected title) in the servlet.I am 
using <a href=""> tag in the xsl to display the title as a link.
Use the getParameter method inside the servlet to get the value of the selection.
why do you use dopost to get the data and doGet to do the processing in Ex:4.8. Why can't we do the processing in doPost?
Which program is Ex. 4-8, the printed text or the online revision? I wanted to one thing the first time the user makes a request, and something else every other time. If the way you describe it is correct it would have been better to do the processing in doPost and get the data in doGet because that reflects the intended semenatics of these operations.
Can we use the tag "DetailedPageUrl" already provide in amazon response and display it along with each book title? The link
 will take the user the amazon website for that specific item where the page shows pics, info, and the reviews for the selected 
title.
Good idea, but I want to see you use XSLT to fish out the reviews, so I guess for my purposes what you suggest is too easy.
2 things:
Do we need to use Model 2 Architecture for project 5?
Is it ok to just save the xml from amazon, the xsl, and the output as files 
(i.e. like in your example XmltoHtml.java) instead of playing around with streams?
You would use Model 2 if you had several pages representing different views, but it is not necessary for a simpler application. What you describe is OK as long as you have a user interface to allow the user to enter search terms and select a book to get reviews.
I get this error: "javax.xml.transform.TransformerFactoryConfigurationError: Provider org.apache.xalan.processor.
TransformerFactoryImpl not found"
What are you trying to do? XmlToHtml.java does not use this class. Version 1.4 and above include the xml packages.
I tried to create a servlet similar to XmltoJava.java, but I got this error when I compiled the servlet file. Error was "javax.xml.transform.TransformerFactoryConfigurationError: Provider org.apache.xalan.processor.
TransformerFactoryImpl not found", and this caused the error:  
    
TransformerFactory factory = TransformerFactory.newInstance();
Transformer translate = factory.newTransformer(
                 new StreamSource(new File("SearchResults.xsl")));
translate.transform(new StreamSource(new File("AmazonXML.xml")), new StreamResult(new File("Amazon.html"))); 
Don't use the compilation shown in the book because it uses jdk 1.3. Use java 1.4 or 1.5 and only include servlet.jar in the classpath.
I get this exception error "javax.servlet.ServletException: Cannot allocate servlet instance for path 
/examples/servlet/SimpleXSLTServlet" and the root cause is "java.lang.NoClassDefFoundError: SimpleXSLTServlet 
(wrong name: servlet/SimpleXSLTServlet)".  I put this file in examples/WEB-INF/classes/SimpleXSLTServlet.class. Could you help me 
debug this?
It looks like your servlet is in a package and it is not in a folder with the package name. Make a folder called pack, in classes, where pack is the name of your package. Include pack in the URL.
Are we allow to bring a cheat sheet for the Security Test ???
No. This is a posttest and I want to use the same protocol as I did for the pretest.
JAAS question - which interface should we implement to include code that will be 
executed by an authorized user?
PrivilegedAction
Could you tell me what is wrong with this statement:
<xsl:template match="ASIN">
      <input type="hidden" name=<xsl:value-of select="ASIN"/>>
   </xsl:template>
I can't get it to work.
You need to put the value of the name attribute in quotes.
How do you retrieve data from XML element and set it to be the value of HTML <input value="XMLdata"> tag's 
value?
If you are using an input tag you need to specify the type attribute, for example text or radio. You could also use a select tag and list the data in option tags as in the ice cream example.
I want to get the ASIN number from the XML file sent by Amazon, and send it to the servlet using a HTML form.  But I can 
not make it work.  Can you give me some ideas?  Thank you very much.

<xsl:template match="ASIN">
<form method="GET" action="http://localhost:8080/examples/servlet/SearchServlet">
      <input type="hidden" name="{ASIN}"></input>
      <input type="submit" value="Read reviews" name="submit"/>
      </form>
</xsl:template>
The hidden tag needs a value and a name. What you have as the name should be the value. Compare with the music example.
Where is the music example?
There is a link above on this page to Understanding JavaServer Pages Model 2 Architecture.
professor, thanks for the photos :)
I got this error after building with ant.

javax.servlet.ServletException: [Microsoft][ODBC SQL Server Driver][SQL Server]C
annot open database requested in login 'sba10'. Login fails.
I got this error after building with ant.

javax.servlet.ServletException: [Microsoft][ODBC SQL Server Driver][SQL Server]C
annot open database requested in login 'sba10'. Login fails.