| ★ wanayoo — archive 1999 http://javaboutique.webdeveloper.com/tutorials/Simple_JSP/index2.html | Nouvelle recherche | Portail wanayoo |
![]() | ||||||||||||||||
Tutorials : : A very simple JSP-architecture Part 2
A very simple JSP-architecture Part 2In my last article the architecture and code for a simple "customer-lookup" application was presented. The main idea was to build on the MVC-architecture and to implement this using only JSP-pages and JavaBeans. Furthermore each window of the application should be handled by a controller/view-pair of JSP-pages, where the controller was always invoked with a "command", that told the controller which function to handle. In the current article I'll show how simple it is to add a couple of new functions to this page, but inspired by a few flaws in the code presented in the first article I'll also discuss briefly the important topic "portability of JSP-pages". Also, while we're into the application error arena, I'll give a few tips on how to ease debugging JSP-pages. Are JSP-pages portable?Since Java is designed to be a portable language (you know--"Write once, run anywhere") you might think that JSP-pages are also portable. Since a JSP-page eventually is being translated into a servlet, which is Java class-file, it will be just as easy to port it to other computers and operating system as any other class file. But the conversion from a JSP-file to a servlet may be handled somewhat differently by today's servlet engines. I tested my code on an older version of JRun, and after the article was published I had the opportunity to test the code against two other servlet engines: WebSphere and SUN's JSWDK. This revealed two flaws in my code:
I have observed minor differences like this many times before when working with the JSP-technology, and even if the two actual cases are rather simple to debug and correct, you should always be prepared to do modifications in a JSP-application when moving to another servlet engine. By the way, you may have wondered why I do not use upper case letters in filenames--for example ctrlCustomerInfo.jsp--to make them more readable. The reason is that servlet engines--like the Java language itself--are case-sensitive. But when writing an URL in the browser's address field you normally prefer to write in lower case letters and most users do not expect an URL to be case sensitive. Debugging JSP-pagesThe major problem with using JSP-pages in a web-application is actually how to locate some of the syntax errors that always will occur when you're coding--no matter how hard you try to avoid them. Below I'll give you a few tips to make life easier for you.
|
| |||||||||||||||
