What is a framework?
A framework is a support structure for developing applications. It may include support programs and libraries.
When I write a binary file with the method writeInt (from the 
DataOutputStream constructor), it writes each integer as four bytes, so a 2 
would be written as 0 0 0 2. How can I get it to write one byte at a time?
^ Nevermind, just needed to use writeByte.
In a server program, when using a BufferedReader.readLine() to read 
from the client program, is there a way to clear the BufferedReader before 
requesting the next line from the client? 
I'm not sure what you are trying to do. The readLine method reads the next line from the client. It is independent of what was read previously.
What does the "OutputStreamWriter" class do?
It writes characters (according to a specified encoding).
Can we use a GUI Builder for Project 3?
OK
I'm having problems getting the Database examples from the textbook 
chapter 3 to work correctly.  I have Access 2000 on my laptop, I went through 
the steps that were outlined in chapter 3 and set up my database accordingly.  
I even got the first example, Connect.java, to work fine.  However when I try 
Create.java (the second example in the same chapter) to actually create the 
tables and populate them with data, nothing happens...the Customer table gets 
created but it's empty when I open the database.  What could I be doing wrong? 
Any hints/ideas? 
If you can connect then Create.java should work. The name in the URL must exactly match the ODBC data source name (including case). Reopen Access after you run Create to see the new tables.
So I got my create.java to work fine...I had another question regarding
 the assignment that's due tomorrow.  I assumed we could use any kind of 
database, and I had one already about books, authors and publishers, so I just 
used that instead.  Is that OK? I read the assignment again and it says that we
 could use a sports database or a CD collection database...
It's OK as long as you have more than one table and some queries involve more than one table.
I was busy with the midterm last weekend and did not get time to 
work on  project#3. Can we get some extra time, at least till thursday? 
Please turn it in as soon as it is completed.
C++ provides a facility to set column width when printing to standard output as in
cout << setw(10) << "IDENTIFIER" << setw(30) << "NAME" << endl;
this way I can display a table on the console.
Does Java have a similar utility?
Java 5, the current release, has a printf method that works like the C version, for example System.out.printf("%s %3d", name, age);
What's Model 2? I noticed it is not in Chapter 4 or 13? I know you 
mentioned it in class, but I don't remember what you said.
See the link to the article on the course web site which explains it and give the CD shopping example I demonstrated in class.
I have been trying for several days to get your servlet examples to run
 on my Tomcat 5.5 installation. For example, I place the .class file of 
Welcome.java in the folder where the Tomcat examples reside, but I get the 
following message from Tomcat:
The requested resource (/servlets-examples/servlet/Welcome) is not available.
I can get the examples that come with Tomcat to work, but not any other servlet
 that I add.
In web.xml in the WEB-INF folder add (for the Welcome servlet)
    <servlet>
        <servlet-name>Welcome</servlet-name>
        <servlet-class>Welcome</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>Welcome</servlet-name>
        <url-pattern>/Welcome</url-pattern>
    </servlet-mapping>
Restart Tomcat. In version 5.0.28 the URL would then be
http://localhost:8080/servlets-examples/Welcome
For Lab4, does the entire application have to be in Model 2 
architecture, or just the login page. The reason I ask is because we can make 
Project 3 as an applet which is served only if the login is successful?
I don't want an applet which is run on the client. The client should just be HTML. A servlet controller should dispatch to JSP views.
Can you color code (or indent) the questions(or answers)? Its getting 
messy in here.
Good idea . I'll do it as soon as I get a chance.
Tomcat 5.5 is not recognizing the keyword else inside a JSP.
The tags should be something like
<% else { %>
<% } %>
From the Project4 requirements: A servlet controller will dispatch to 
a login page if the user has not logged in or if the login was unsuccessful.
What does it mean to dispatch to a login page. I saw the following code in the 
JSP Model 2 web page:
String url="/jsp/shopping/EShop.jsp";
      ServletContext sc = getServletContext();
      RequestDispatcher rd = sc.getRequestDispatcher(url);
      rd.forward(req, res);
I don't know what this does.
It transfers control to the JSP specified in the URL.
In the article, file: Cart.jsp & ShoppingServlet.java, have the 
following line of code:- 
"Vector buylist = (Vector) session.getValue("shopping.shoppingcart");"
Can you tell me what this does and where is the value "shopping.shoppingcart"
declared or defined?
It gets the Vector of items that were put into the shopping cart earlier in this session, if any. "shopping.shoppingcart" is an arbitrary tag. You just have to use the same tag for both "get" and "put".
I can't get a JavaBean program to connect to the database. However, I make the neccessary 
modifications to run the program as stand-alone and it connects. What do I need to do to connect?
Model what I do in SalesServlet.java, because that works.
The Model 2 Architecture article discussed in class shows the bean (model) communicating to the 
database, not the servlet. That is why I'm trying to connect from the bean, but it's not working for me.
The article I reference does not use a database. Connect from the servlet.
Is there a way to output HTML from within the <% %> (JSP Tags)? 
It is frustrating to open/close tags while in a loop.
You can always use out.println, but if you did all that you would be writing the servlet. The idea is to write a web page with minimal Java. One way to do that is to use a bean which hides the Java in methods. Another is to use custom JSP tags, but we haven't covered that.
Whats the difference between :
ServletContext sc = getServletContext();
RequestDispatcher rd = sc.getRequestDispatcher(url);
rd.forward(req, res);

AND

res.sendRedirect(url);
See http://www.theserverside.com/discussions/thread.tss?thread_id=742
I tried the following code in line 28 of my jsp file "LoginError.jsp":



and I get the following error:

org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 28 in the jsp file: /LoginError.jsp
Generated servlet error:
C:\Documents and Settings\Juan\.netbeans\5.0\jakarta-tomcat-5.5.9_base\work\Catalina\localhost\
CECS471_Project4\org\apache\jsp\LoginError_jsp.java:61: cannot find symbol
symbol  : class UserBean
location: class org.apache.jsp.LoginError_jsp
      UserBean user = null;
      ^

The class UserBean exists. Moreover, my servlet file uses UserBean even before
the LoginError.jsp file executes.
You may have deployed UserBean.class in the wrong folder. It might work in the "classes" folder in WEB-INF. Iput my bean in a package and put the .class file in a subfolder of "classes" with the package name, so you might try that.
I can't get the jsp: tag to post in your question page. This is what is missing fromm the 
previous questions:
useBean id="user" class="UserBean"
Of course it includes the other characters as per your examples.
You need to escape the HTML brackets. Use &lt; for the left angle bracket and &gt; for the right.
In your example of java:usebean, you have your bean class in a package.
My bean class is in the default package. Do you think that is the problem?
It might be.
I was wondering if you could come to school earlier tomorrow. The jsp:useBean is not working 
for me. I've asked other students, but they have not used jsp:useBean.
I'll try but I have an appt. at 10 with a fence builder so it would be 11 at the earliest, if that.
I fixed the problem with the jsp:useBean action by placing everything in a package. The lesson 
learned is that if you're using NetBeans IDE, you can't use the default package. This also might be true 
for all Java.
It does seem that beans should be in a package.
When I run the sax class from chapter 13, it cannot find any of my xml files that are in the same 
directory. What am I doing wrong?
You must use a Java version 1.4 or greater. Also the current directory must be on the classpath. Execute SET CLASSPATH from the command prompt. If it is empty, no problem, but if nonempty, it must have a dot, ., representing the current directory. If it doesn't then execute SET CLASSPATH= to reset the classpath variable and it should work.
The Dom class (in the same directory) can see the xml files just fine.. and I've gotten the same 
result with the Sax class on two different computers. Has anyone else had this problem?
You need the correct import statements the same as I use in Sax.java. You haven't said exactly what error message you get. That would help to diagnose the problem.
Nevermind, I'll just use DOM for the project.
Sax works.
In your book you show us how to get the value of a tag as in

How do we get the value of an attribute?
See titles.xml
<xsl:template match="title[@full='false']">
Ok. It seems that when we recv. the XML it has a "xmlns" attribute for 
the "" which does not allow the XSLT processors to parse 
anything other than the "/" (Root) tag? How do we process other tags?

<ItemSearchResponse 
  
xmlns="http://webservices.amazon.com/AWSECommerceService/2005-10-05">
It's not clear how you are using XSLT. If you get the XML response from amazon and then use XSLT locally there shouldn't be any problem. If you include XSLT as part of the request as Amazon allows then see this documentation page
http://docs.amazonwebservices.com/AWSEcommerceService/2006-06-28/
From a student:
For those who can't access elements other than the root:- -Extract from Amazon Web Services Documention "You must create a namespace prefix at the top of your style sheet. In previous versions of ECS, it was possible to use the default namespace, which meant that you did not need to specify a namespace to access elements in the response. This is no longer the case. You use the namespace in your XSL stylesheet to access elements in your ECS response."
Go to http://docs.amazonwebservices.com/AWSEcommerceService/4-0/ scroll down the page and read Building an XSL Style Sheet with Namespaces Basically, the XSLT file should have the following at the top <?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:aws="http://webservices.amazon.com/AWSECommerceService/2004-03-19"> Then, the tags should be prefixed with the aws namespace as in <xsl:template match="aws:Items"> Notice that the tag "Items" has "aws:" in front of it.
How can we access the reviews for a book?
Make sure you use "large" as part of the request as I did in my example. Then the response will contain the reviews.
For assignment 5, in order to perform the XSLT transformation, do I first have 
to place all the xml returned from Amazon in a file, and then use a an XSLT 
transformation on the file? All the examples I could find (both in the chapters
 as well as online) use an XML file, however, we get a stream from amazon when 
we send the keywords.  Is there a way to apply XSLT transforms directly on a 
stream or do we have to first write out that stream to a file?
Please let me know!
I expected you would get the response and then apply an XSLT transform locally. It helps to view the response in a browser because the browser will format the XML. You can add the XSLT transform as part of the request but then you have to follow the rules as mentioned in the answers above.
How do I convert a char[] to a byte[]?
Pass the array to a String constructor to get a String. Then use the getBytes method to convert the string to a byte array.
Student input:
For those who are having trouble with applying select templates in the root element, you have to apply templates to all in the root. So you would have an empty OperationResponse template to ignore it and than Items template. After the root element, select can be used without a problem.
I need the servlet controller to serve an html page as its response. 
How can I go about doing that?
You can create a String and send it with out.println.
Even though my "BookList.html" file exists (it is generated by the 
program) in the same root folder of the application, I get an error saying 
that the file does not exist? Any idea what I must do to make this work?
If you are using Tomcat, make sure BookList.html is in the same folder as the index.jsp, probably webapps/ROOT. If you want to use a different folder you have to adjust the URL to reflect that path, or configure the path in web.xml
Are we responsible to know about Filters?
No.
How do we find out our grade?
email me. I'll b e out of town after today so I may not get it until I get back.