Louise Haydu

Ranch Hand
+ Follow
since Aug 17, 2000
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Louise Haydu

I am grateful to javaranch for all of the resources provided for studying for this exam.
I used Manning's Study guide, read the servlet spec and most of the JSP spec, and did lots of mock exams.
The link below is a reference to Sun's JSP Syntax document for JSP 1.2
Sun's JavaServerPages Syntax
The first sentence on the first page of this document states:

Spaces are not allowed between an equals sign and an attribute value.


[ July 21, 2003: Message edited by: Louise Haydu ]
In one of the earlier responses, the following statement was made:

In TC 4.01 it's a HashTable, declared private, in TagSupport. The getValue, getValues, removeValue, setValue public methods are not used by local code. BodyTagSupport does not call any of these methods either.


I thought that BodyTagSupport would be able to call these methods because it is extended from TagSupport. Also, the JavaDocs for BodyTagSupport show these methods as available to BodyTagSupport throught inheritance.
Can anyone clarify this point?
The only thing that I can come up with is the following quote:

Be sure to use the braces characters, {}, to enclose if, while, and for statements even if the scope contains a single statement. You can enclose the entire statement with a single scriptlet tag. However, if you use multiple scriptlet tags with the statement, be sure to place the opening brace character, {, in the same statement as the if, while, or for keyword.


Based on this quote, I'm assuming that if an opening brace is not on the same script as the if statement that the translator creates a blank line as the body of the statement.
Here's how the jsp was translated using Tomcat 4.1
Some later versions of TomCat have the invoker servlet mapping commented out in the conf\web.xml file. If this is your first attempt at running a servlet in TomCat, this may be your problem.
Yes, both a and d are correct.
You can verify this by installing TomCat and running a test using the sample code (supplied on the CD that comes with the book) as the source for AddressBean.
Since a jsp generates a servlet, you can find the actual servlet code in a *.java file in the work directory of TomCat. If you examine that file, you will see how the getProperty action is translated into Java code.
When I looked at the first scriptlet on page 267 of the book, I thought that the code would translate into java as:
out.print(address.getStreet());
In this case, you would get a compile error because "address" is out of scope.
However this is not the case... the translator uses the findAttribute method (page 222) instead and the code compiles and runs successfully.
Hope this helps!

[ June 19, 2003: Message edited by: Louise Haydu ]
I think the following statement would be corrected if you changed the word "parameters" (in bold below) to "attributes".
The parameters are local to the virtual machine (VM) in which they are created. If information needs to be shared between servlets in a distributed environment, it should be placed in a session (which migrates with the user between servers), or a store such as a database, EJB, or directory service.
[ June 19, 2003: Message edited by: Louise Haydu ]
The line in answer a:
<jsp:getProperty name="address"
property="street"/>
is actually translated using the following method of PageContext (see page 222 in your book):
Object findAttribute(String name)
This method search for the named attribute in page, request, session (if valid) and application scope(s) in this order and returns the associated value.
The translator generated code to look for the address attribute and then accessed the street property.
I had the same question and only discovered this answer after creating and running a jsp to test this out. When I looked a the java code generated for the jsp page, I found it was using the "findAttribute" method, which is shown on page 222.
[ June 19, 2003: Message edited by: Louise Haydu ]
As far as I can tell, Jasper is the jsp translator, but in its error messages, it is referring to itself as a compiler.
I think the compilation process would be performed by the javac program, not Jasper.
This leads me to believe that what we have here is a translation error coming from the Jasper "translator."
Can anyone clarify?
I am having trouble understanding why a compile error was generated and not a translation error.
As I understand it, you cannot have more than one useBean statement with the same value for "id" in a translation unit.
Since translation happens before compilation, wouldn't the use of "address" as the id for two jsp:useBean statements result in a translation error?
Based on this line of thinking, I thought the correct answer was "a".
Am I missing something?
I found my problem... when I looked in the conf\web.xml file, I wasn't looking in the right place for the "invoker" tags. The tags that need to be uncommented are as follows:
<!-- The mapping for the JSP servlet -->
<servlet-mapping>
<servlet-name>jsp</servlet-name>
<url-pattern>*.jsp</url-pattern>
</servlet-mapping>
Everything is working fine now!
19 years ago
I just downloaded and installed Tomcat 4.1.24 and am also receiving 404 errors when I attempt to run servlets.
The "invoker" tags are not commented out in the config\web.xml file.
Here's info on my problem:
servlet class location: "webapps\chapter01\WEB-INF\classes\HelloWorldServlet.class"
web.xml: contains tags to define the HelloWorldServlet
URL used to access: "http://localhost:8080/chapter01/servlet/HelloWorldServlet"
I am using the SCWCD Exam Study Kit book, which contains a CD that has complete workable files for this HelloWorldServlet.
So I decided to use install the Tomcat 4.0 version supplied on the CD in the book and now everything works fine.
Does anyone have any additional insight on the problems I experienced with Tomcat 4.1.24?
Thanks!
Louise
19 years ago
I tried to look at your link via "edit", but received a message telling me that I couldn't do it because I'm not a moderator or administrator.
19 years ago