Please help me get started... JSP
Hey, I'm brand new to web development. But I'd like to get into the field. For various reasons, I would like to start with JSP dev. I'm a C++ programmer, so concepts of OOP are not foreign to me. However, I don't have any idea as to where to start.
I have installed Forte 4.0 software, Apache-Tomcat software, Sun JDK1.3, and JRun 3.0. Now I'm stuck. Although I have set the CLASSPATH, JAVA_HOME, and TOMCAT_HOME roots, I cannot write, compile, debug, or execute JavaServer Pages.
Thank you for your time in assisting me.
Moshe
[564 byte] By [
Shtarkman] at [2007-9-26 2:17:03]

Hi,
For debugging
=============
It seems that JSP runtime errors are impossible to debug. The exception
thrown is always in some compiled servlet code. For example
java.sql.SQLException, java.lang.ArrayIndexOutOfBoundsException,
java.lang.NullPointerException and java.lang.ClassCastException. Is it
possible to debug runtime errors, other than printing multiple checkpoint
statements, which is not an efficient method?
SOLUTION:
There are no hard and fast rules to do that. It is very dependent on
your JSP engine. In general, you need to find where your .java files
are. You need to tell your JSP engine to leave them around. By default
most engines delete them after creating the .class file. It may get
tricky, though. Some engines put your HTML text into some kind of data
structure (an object dump, basically) so it is not stored in your .class
file. This makes your class files much smaller, and the HTML is not
stored on the VM's stack. This makes it very difficult to debug.
One suggestion is to use Forte for Java to do debugging of JSP codes. It can be
downloaded and purchased from http://www.sun.com/forte. The following is
a short tutorial to demonstrate how to debug a JSP file, set breakpoints,
and watch variable content values during runtime.
1) Set the compiler property for your JSP.
- Go to the Explorer window.
- Select your JSP file.
- Set the Servlet Compiler property to Internal Compilation.
(Hint: Use the context-sensitive Properties window.)
- Set the Debugger property to Servlet/JSPDebugging.
2) Now you will debug the JSP file by setting breakpoints, watching
variables, and switching between the JSP and corresponding servlet.
Set the breakpoint in your JSP file.
- Go to the Source Editor window.
- Select a few lines to watch
- Using the context-sensitive menu (right click), select Add/Remove
Breakpoint. This line will turn red to indicate that there is a
breakpoint for this line.
3) View the breakpoints in the corresponding servlet for your JSP file.
- Go the Explorer window.
- Select your JSP file.
- Using the context-sensitive menu, select View Servlet.
You will see the corresponding servlet in the Source Editor window.
At the bottom of the Sourde Editor window, you should see two tabs,
one for JSP and another for the corresponding servlet.
- Select the servlet's tab.
- Using the context-sensitive menu, select Clone view.
You should see a separate window with the servlet code and
breakpoints. These breakpoints automatically came from the JSP
file.
- Place the JSP file and corresponding servlet window side by side so
that you can simaltaneously view the execution of JSP as well as
the servlet.
4) Select some variables to watch during the execution.
- Go the window containing the servlet's source code.
- Using the context-sensitive menu, select Add Watch.
- In the resulting dialog box, enter a variable name for the Watch
Name.
- Click on the OK button.
- To view the watch variables, go to the Main menu and select View ->
Debugger. At the bottom of the Debugger window you should see a
tab named Watches.
- Select the Watches tab.
You should see the added variables.
5) To start the debugging session, go the Main menu and select Debug ->
Start Debugging.
The execution will stop at the first breakpoint in the JSP file.
If you see the servlet code, there are also execution will stop at
the first breakpoint.
- To continue the execution, go the JSP source code in the Source
Editor window and press Control-F5 to restart the debugger.
Execution will stop at the next breakpoint. In the servlet code,
execution will also stop at the next breakpoint.
- Go to the Debugger window and select the Watches tab to view the
contents of the variables.
6) If you set any breakpoints in the servlet code, those breakpoints
will automatically appear in the JSP file.
This way, you can set breakpoints in either JSP file or corresponding
servlet.
7) While executing the JSP, observe the contents of the variables in the
Debugger window.
8) Once execution has reached its end, close the debugger by going to
the Main menu and selecting Debug -> Finish Debugging.
For more tutorials and demo, please visit:
http://www.sun.com/forte/ffj/demo/online_demo.html
http://access1.sun.com/SRDs/srd_repository/F4JCE_SRD.ps
For information and online support, please visit:
http://forte.sun.com/cgi-bin/WebX
http://www.sun.com/forte/ffj
I hope this will help you.
Thanks
Bakrudeen