tags:

views:

70

answers:

4

Hi,

So I have an example question as follows:

Explain how a JSP page is executed and what kind of problems may occur.

I'm fine with the first part, compile the static html and the scriptlets to java to be served by the servlet etc.

But I'm stumped by what problems may occur? The JSP page is held in memory... so maybe that may exhaust memory? I'm kinda grabbing at straws here...

Adam

+1  A: 

One potentially problematic thing that a lot of people overlook when writing JSP pages is the fact that JSP declarations, i.e.:

<%! String foo = "bar" %>

create instance variables when they get compiled into servlets, which destroys the thread safety of the JSP.

More generally though, common problems include using a semicolon at the end of an expression, or not using a semicolon in a scriptlet; attempting to retrieve parameter or attribute or session values that are null or are the wrong type; using the wrong scope when trying to access variables. All sorts of fun stuff.

yalestar
+1  A: 

There could be syntax in JSP tags or Java code in scriptlets that cause the JSP file to not compile correctly.

Also, there could be tag libraries or Java source file imports that have not been included.

Mr. Will
+1  A: 

I must say that the question is a bit awkward to me. In general when you have a JSP page (executed) it should handle any exceptions that might arise from the use of scriptlets, expressions or other JSP things. When you do not handle those by specifying that the web container should forward control to the error page when an exception occurs, things may go wrong :). Ofcourse an unpredicted error can always arise but thisone can be handled as well by using "Handling Unhandled Exceptions".

So the answer is that there are infinitely many errors which can occur based on what your code is in the JSP page. The thing is you can predict them and handle them in advance?

bastijn
A: 

The client may close the connection, for example if they hit the back button, which is a problem if you are streaming data from the page(pdf,word doc, binary file.)

Milhous