How to debug a servlet?

Answer Posted / madhusudhakar

res.setContentType("text/html");
ServletOutputStream out = res.getOutputStream();
try {
// do your thing here
...
}
catch (Exception e) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
out.println("

");
out.print(sw.toString());
out.println("

");
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How does tomcat servlet container work?

592


What is string tokenizer?

630


Explain the difference between servletconfig and servletcontext in servlet?

567


What is the workflow of a servlet?

719


What is the life-cycle of servlets?

633






What is servlet container?

663


What are the new features added to servlet 2.5?

592


Whether we can get deadlock situation in servlets?

576


What is http servlet?

584


What are the different methods involved in generic servlet?

556


What is the use of welcome-file-list?

571


What is a web application and what is it’s directory structure?

584


How to handle exceptions thrown by application with another servlet?

614


Is that servlet is pure java object or not?

644


Can filter be used as request or response?

540