Uncategorized

Debugging Servlets

• Use print statements; run server on desktop
• Use Apache Log4J
• Integrated debugger in IDE
– Right-click in left margin in source to set breakpoint (Eclipse)
– R-click Tomcat and use “Debug” instead of “Start”
R click
Debug
Start
• Look at the HTML source
• Return error pages to the client
– Plan ahead for missing or malformed data
g
• Use the log file
– log(“message”) or log(“message”, Throwable)
• Separate the request and response data.
p
q
p
– Request: see EchoServer at http://www.coreservlets.com
– Response: see WebClient at http://www.coreservlets.com
• Make sure browser is not caching
– Internet Explorer: use Shift-RELOAD
– Firefox: use Control-RELOAD
• Stop and restart the server

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s