Subscribe to Java/SCJP        RSS Feed
- - - - -

SCJP Notes - Part 8

Icon Leave Comment
1) Static blocks/static methos/static variables are executed first in the order of thier appearance in the code.
After executing static's instance blocks/instance methos/instance variables are executed.
2) The reference may be null when calling a static method from main method.
3) float arr[][] = new float[][10]; is wrong
float arr[][]...
- - - - -

SCJP Notes - Part 7

Icon Leave Comment
1) The final keyword on a method means that the method cannot be overridden in a subclass. But since the main() method is a static method, it can't be overridden anyway. So making the main() method final makes no sense.

2) main method can be final.

3) A class without a main method can be run by JVM, if its ancestor class has a main method....
- - - - -

SCJP Notes - Part 1

Icon Leave Comment
- - - - -

JSP usebeans facts

Icon Leave Comment
1<jsp:getProperty name="test" property="date"/> will print the value of property.

2<jsp:useBean id="test" class="com.Example">
<jsp:setProperty name="test" property="*"/>

3 <jsp:setProperty name="test" property="date"...
- - - - -

JSP implicit objects

Icon Leave Comment
request javax.servlet.http.HttpServletRequest
response javax.servlet.http.HttpServletResponse
pageContext javax.servlet.jsp.PageContext
page java.lang.Object
config javax.servlet.ServletConfig
out ...
- - - - -

Resend Information on page refresh

Icon Leave Comment
The message when refreshing a page is displayed when session is being used by the JSP/Servlet.

In Servlet, session is got by:
HttpSession session = request.getSession(true);

In JSP the way is:
<% page session="true"%>

Image reduced in size
- - - - -

Directives as tags

Icon Leave Comment
Alternative tags for directives
< import="java.util.*" />

instead of
<%@ page import="java.util.*" %>

The use of tags helps in better compatibility with JSTL and custom tags
- - - - -

Work that can be done with request and response

Icon Leave Comment
1 getParameter
2 cookies
3 request method (GET/POST)
4 getSession

1 setParameter
2 getWriter
3 setContentType
4 addCookie

out in JSP refers to buffered version of PrintWriter which is known as JSPWriter
session has getAttribute("name") and setAttribute("name","value")
- - - - -

The HTML you thought to be present in your JSP

Icon Leave Comment
Consider the code below:

- - - - -

Use Encoded URL in the form tag in JSP

Icon Leave Comment
<% String url = response.encodeURL("Myjsp.jsp"); %>

<form method="post" action=<% url %>?param=value")

- - - - -

Compiler error for unreachable code

Icon Leave Comment
A sample:

while ( false ) {	System.out.println ( "Value" );}while(3>4) {	System.out.println ( "Value" );}
- - - - -

Prototype Pattern

Icon Leave Comment
The prototype pattern is used in cases where the cost of creating a new object is much more than simply editing the attributes of an already existing object. So this pattern should be used when one has the privileges to modify the desired attributes of the object.
In java, the prototype of an object can be got by using the clone method. The method...
- - - - -

Object Pool

Icon Leave Comment
Connection pooling is the process of maintaining a pool of connection and reusing them each time some statement is to be executed in the database. It is a general concept which can be applied in any programming language, but here we will implement it in Java programming language.

A class will maintain all the connections in a vector...
- - - - -

Singleton Pattern

Icon 1 Comments
The Singleton pattern is used for classes which should have only one instance in the application. The other classes can't invoke the constructor directly because it is declared private and some public static method is provided which returns the single instance. This pattern makes the instance available globaly and thus should be used...

  • (2 Pages)
  • +
  • 1
  • 2

February 2020

1617181920 21 22

Recent Entries

Recent Comments

Search My Blog

0 user(s) viewing

0 Guests
0 member(s)
0 anonymous member(s)