Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

compile and translation time errors

 
sri lakshmi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hanumant Deshmuk book chapter14 review question no 9.
<body>
<%@ page import='AddressBean' %>
<% { %>
<jsp:useBean id="address" class="AddressBean" scope="session"/>
<% } %>
<jsp:useBean id="address" class="AddressBean" scope="session"/>
<jsp:getProperty name="address" property="street"/>
</body>
which of the following is true?
a. it will give translation time error
b. it will give compile time errors
c. it may throw run time excep
d. it will print the value of the street

when I invoked this page, it gave me org.apache.jasper.compiler.compileException ...
The answer given was a.
How can we find out whether an error is a compile time or translation time error?
 
Amer Khan
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
simple answer is:

jsp errors----r--DETECTED -- at--------translation time
java code(syntax)errors---r---DETECTED--at-compile time
"org.apache.jasper.compiler.CompileException: /test1.jsp(10,0) useBean: Duplicate bean name: address"
This clearly states a translation error! because this is a JSP ERROR!
[ June 14, 2003: Message edited by: Amer Khan ]
 
Louise Haydu
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
sri lakshmi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Following is the detailed message that I got when I invoked test1.jsp. From the message, I couldn't figure out that it is a translation error. Are there any tips for finding this out?

org.apache.jasper.compiler.CompileException: /test1.jsp(10,0) useBean: Duplicate bean name: address
at org.apache.jasper.compiler.BeanGenerator.checkSyntax(BeanGenerator.java:130)
at org.apache.jasper.compiler.BeanGenerator.generate(BeanGenerator.java:100)
at org.apache.jasper.compiler.JspParseEventListener$GeneratorWrapper.generate(JspParseEventListener.java:831)
at org.apache.jasper.compiler.JspParseEventListener.generateAll(JspParseEventListener.java:241)
at org.apache.jasper.compiler.JspParseEventListener.generateHeader(JspParseEventListener.java:283)
at org.apache.jasper.compiler.JspParseEventListener.endPageProcessing(JspParseEventListener.java:195)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:215)
at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:546)
.
.
.
.
 
Louise Haydu
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Ken Januski
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My understanding is that Jasper is the compiler for Tomcat. But I'm guessing that it also does the translating. Something has to do the translating. So just guessing I'd say that the errors referring to syntax at top are part of the translation process not the compilation process.
But this is all guessing on my part. Still waiting like everyone else for a definitive answer. Though I think the relevant part of the question in the book is: can you have two identical ids? If not who will complain? The answer is no and this will be detected during translation before compilation even occurs.
 
Panagiotis Varlagas
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"JavaServer Pages™ Specification", Version 1.2
JSP.4.1 <jsp:useBean>
[...]
The id Attribute
The id=”name” attribute/value tuple in a jsp:useBean element has special meaning
to a JSP container, at page translation time and at client request processing time.
In particular:
•the name must be unique within the translation unit, and identifies the particular
element in which it appears to the JSP container and page.
Duplicate id’s found in the same translation unit shall result in a fatal translation error (emphasis is mine)
[ June 17, 2003: Message edited by: Panagiotis Varlagas ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic