Tags » JSP

Logging errors to a log file in servlets

1. log(String message)
2. log(String message,Throwable t)
These log methods belong to HttpServlet class and these are used for debugging and they can write the data to a web servers log file. 57 more words

Java

The common methods in a servlet

public void init() throws ServletException{}

public void service(HttpServletRequest req, HttpServletResponse resp) throws IOException,ServletException{}

public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException,ServletException{}

public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException,ServletException{} 72 more words

Java

Local vs Instance variables

When a request is initiated JSP is created and loaded into memory and a thread is started, for subsequent requests separate threads are created.
When you declare a variable inside the scriptlet its a local variable and each thread gets its own copy of each local variable. 24 more words

Java

HTML Comment vs JSP Comment vs Java Comment

HTML Comment: <!– –> This tag is used but if a html comment is used in a jsp the java code inside it is compiled and executed but the value is not shown in the… 41 more words

Java

Five tags of JSP

<% %> – Scriptlet
<%= %> – Expression
<%@ %> – Page Directive
<%– –%> – Comment
<%! %> – Declaration

To define the conditions for the JSP engine to convert it into a servlet you define it in the JSP Directive but to add the classes you can make use of import attribute of the page directive. 6 more words

Java

Why use a constructor??

A constructor let you jump into middle of the object creation step – into middle of new.

Creating an object and then calling the setter method is a two step process and if you would like to avoid it then you can directly go for the constructor.

Java

Using Regular Java Classes in JSPs

Create the business logic in the Java class and you can use the objects of the class to call the respective methods. But inorder to do so you will have to import the java classes to your jsp. 16 more words

Java