Set - 4

Question 6 :

How to Retrieve Warnings?

Answer :

SQLWarning objects are a subclass of SQLException that deal with database access warnings. Warnings do not stop the execution of an application, as exceptions do; they simply alert the user that something did not happen as planned. A warning can be reported on a Connection object, a Statement object (including PreparedStatement and CallableStatement objects), or a ResultSet object. Each of these classes has a getWarnings method, which you must invoke in order to see the first warning reported on the calling object
SQLWarning warning = stmt.getWarnings();
if (warning != null)
{
while (warning != null)
{
System.out.println(\"Message: \" + warning.getMessage());
System.out.println(\"SQLState: \" + warning.getSQLState());
System.out.print(\"Vendor error code: \");
System.out.println(warning.getErrorCode());
warning = warning.getNextWarning();
}
}


Question 7 :

How many JSP scripting elements are there and what are they?

Answer :

There are three scripting language elements: declarations, scriptlets, expressions.


Question 8 :

In the Servlet 2.4 specification SingleThreadModel has been deprecated, why?

Answer :

Because it is not practical to have such model. Whether you set isThreadSafe to true or false, you should take care of concurrent client requests to the JSP page by synchronizing access to any shared objects defined at the page level.


Question 9 :

Is JSP technology extensible?

Answer :

YES. JSP technology is extensible through the development of custom actions, or tags, which are encapsulated in tag libraries.


Question 10 :

Can we use the constructor, instead of init(), to initialize servlet?

Answer :

Yes , of course you can use the constructor instead of init(). There's nothing to stop you. But you shouldn't. The original reason for init() was that ancient versions of Java couldn't dynamically invoke constructors with arguments, so there was no way to give the constructur a ServletConfig. That no longer applies, but servlet containers still will only call your no-arg constructor. So you won't have access to a ServletConfig or ServletContext.