• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why jsp compiler creates exception(jasperException)during compile time,but incase of javac its not?

 
Chinmaya Chowdary
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Why jsp compiler creates exceptions( jasperException) during compile time, but incase of standalone programs,(using javacompiler) its not?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why jsp compiler creates exceptions( jasperException) during compile time

Can you explain what you mean by creating exceptions ?
 
Chinmaya Chowdary
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In standalone java, if there is undefined symbol used,(if the variable 'a' is not declared anywhere, and if we call like, System.out.println(a); it will show an error, and no exception object, but incase of jsp if we call out.println(a);(provided 'a' is not declared anywhere),it will throw jasperException. What is the reason? Thankyou.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is Tomcat's way of telling the user that its JSP cannot be compiled. I think it's a design decision to do so. Jasper (Tomcat's JSP Engine) translates the JSP into a servlet and tries to compile it. You will agree that throwing an exception is a common way to tell that something went wrong, and that's what Jasper does.
 
Chinmaya Chowdary
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thankyou Sir. What is the reason for creating exception object, instead of just showing there is a syntax or symmantic error, like incase of what java compiler do, without creating an exception object? What may be the design issues that jasper compiler keep in made. Please reply.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Imagine the scenario. Jasper tries to compile and find an error. Jasper has nothing to do with the user interface. Where is he going to send the error message ? I think the best way to do it is to throw an exception and let the caller show the error where it wants, and the way it wants.
 
Chinmaya Chowdary
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thankyou Sir.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic