MullaBihari
MullaBihari

Reputation: 61

What is the best way to debug a JSP file, like we do a Java class?

I use Developer tool in IE and FireBug in FF but still I do not get to debug JSP as easily I can debug a Java class. Please suggest some useful way out.

Upvotes: 4

Views: 12731

Answers (3)

My solution is create class in root of project with single public static void method, set breakpoin on call this method and then call it iside of jsp.

package com;

public class JspBreackPointer {
/**
* <%@ page import="com.JspBreackPointer" %> 
* <% JspBreackPointer.stop(); %> in jsp
*/
public static void stop(){

    }
}

enter image description here

Upvotes: 0

mrflash818
mrflash818

Reputation: 934

I used to put debugging messages to myself, as JSP output inside of HTML comments. It is a last resort, as you have to reload the page each time, restage the JSP page each time.

Just be quite careful not to do this with anything security-related (like passwords and such).

<!-- <% 
    java code statements... 
    out.println( stuff );
%> -->

Then I would have my web browser view the HTML source of the page, to look at my "hidden" debugging info.

Upvotes: 0

Matthias
Matthias

Reputation: 2775

you can't debug JSPs in your browser, as they are executed on the server side. you will need the debugger of the IDE you use to write the JSP. (eclipse and IntelliJ have debugging capabilities for JSPs. all you need to do is to add a breakpoint to that line)

Upvotes: 1

Related Questions