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.
[java]System.out.println("Hi SPLessons");[/java]
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
Description
Following are the points to debug servlet.
In a web project, Servlets are placed in a source folder where servlet code will be opened in any editor.
Set the breakpoints to the code by click on the margin of the code in the editor.
Make sure that server should be configured on the project.
In the project explorer open the option Debug on server and check the server again.
At the point when the break point is hit, the Debug will be opened.
After completion of debugging save the servlet and wait for refreshment of the application.
Go to Debug toolbar and click on resume then code will be re excited.
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.
[java]<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>[/java]
Using Comments
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
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("");.