Is there an equivalent to cfdump in JSP

2019-08-08 17:52发布

I have been asked to do some work in the .jsp environment. I have very little experience and in order to better understand where I am starting I'd like to be able to "dump" some variable to look at. Coming from the CF world where cfdump is invaluable I am hoping there is something close in jsp but I can't seem to find it.

So the question is : Is there a jsp equivalent to cfdump or writeDump ? Or is there some native java that would get me close?

2条回答
放荡不羁爱自由
2楼-- · 2019-08-08 17:58

Depending on the complexity of the object you are dumping, you could convert it to JSON and then use browser debugging tools and console.log(). What is console.log?

If you want the results outputted within the browser (like CFDUMP) the best option is to serialize as JSON and use CFDUMP for JavaScript: http://www.petefreitag.com/item/609.cfm

NOTE: CFDUMP for JavaScript is used on http://cflive.net/ for safely dumping objects with ColdFusion 9 & RAILO.

查看更多
兄弟一词,经得起流年.
3楼-- · 2019-08-08 18:15

One approach I use is to set up your servlet container to allow debugging. You can then set up a breakpoint on the code in question. When you hit the breakpoint, your IDE will let you inspect all the variables in scope.

It'll depend on the IDE and server you're using, but if you're using Eclipse and a server which Eclipse is managing, it's built-in: http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.wst.server.ui.doc.user%2Ftopics%2Ftdbgjsp.html

查看更多
登录 后发表回答