Servlets - SPLessons

Servlet Debugging

Chapter 42

SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

Servlet Debugging

Servlet Debugging

shape Description

Servlet Debugging, It is always challenging task to perform debugging in any technology, Servlets are utilized to transform huge data between the client and server. While performing code compilation developer may get an error then sometimes it may be difficult to identify the error, at this time developer will approach a method called tracing method by using the System. out. println (“”), this is used to display the output. Following is the syntax to use System.out.println(“”).

What Is System.Out.Println()

  • out is an object PrintStream class defined in System class. out is declared as public, static and final.
  • The println() is a method of PrintStream class.
  • The println() method is called with out object.
  • The out object is called with System class.
System.out.println("Hi SPLessons");

The debugger is the tool which shows developer to find the ways to detect the errors such as compile time errors, run time errors. Here developer may use breakpoints and suspending threads.

Debugging Servlet

shape Description

Following are the points to debug servlet.


shape Breakpoints

Breakpoints permit clients to suspend the execution of a system at a specific area. Breakpoints are normally appeared in the UI alongside the source code. At the point when a break point is experienced amid execution of a project, the system suspends and triggers a SUSPEND troubleshoot occasion with BREAKPOINT as the reason. Following is the way to keep breakpoints in the source code.

<extension id="javaBreakpointMarker" point="org.eclipse.core.resources.markers">
	<super type="org.eclipse.debug.core.breakpointMarker"/>
</extension>

<extension id="javaExceptionBreakpointMarker" point="org.eclipse.core.resources.markers">
	<super type="org.eclipse.jdt.debug.javaBreakpointMarker"/>
	<persistent value="true"/>
	<attribute name="org.eclipse.jdt.debug.core.caught"/>
	<attribute name="org.eclipse.jdt.debug.core.uncaught"/>
	<attribute name="org.eclipse.jdt.debug.core.checked"/>
</extension>
<extension point="org.eclipse.debug.core.breakpoints">
	<breakpoint
		id="javaExceptionBreakpoint"
		markerType="org.eclipse.jdt.debug.javaExceptionBreakpointMarker"
		class="org.eclipse.jdt.internal.debug.core.breakpoints.JavaExceptionBreakpoint">
	</breakpoint>
</extension>


Using Comments

shape Description

Remarks in code can help the investigating procedure in different ways. Remarks can be utilized as a part of loads of different routes in the troubleshooting process. The Servlet utilizes Java remarks and single line (//…) and various line (/* … */) remarks can be utilized to incidentally evacuate parts of your Java code. On the off chance that the bug vanishes, investigate the code you just remarked and discover the issue. The detailed overview of comments already explained in Core Java

Summary

shape Key Points

  • Servlet Debugging – Debugging is the way to trace the program.
  • Servlet Debugging – Breakpoints will be implemented by resource markers.
  • Servlet Debugging – To trace simple applications most of the developers will use System.out.println(“”);.