Search results for 'dead code'. 1 post(s) found.

  1. 2008/10/27 How to add a declaration on JSP code ?
2008/10/27 14:07

How to add a declaration on JSP code ?


If you have developed C or C++ program, you may know below examples.

// printf( "a.out");

/*
  printf( "b.out");
*/


Above code have no bug, but no code will be compiled, because it's all declarations.

In JSP, you can make declarations as well. In some documents, a declarations is also called as remark.

To add a declaration, you must use the <%! and %> sequences to enclose your declarations, as shown below.
<%@ page import="java.util.*" %>
<HTML>
<BODY>
<%!
    Date theDate = new Date();
    Date getDate()
    {
        System.out.println( "In getDate() method" );
        return theDate;
    }
%>
Hello!  The time is now <%= getDate() %>
</BODY>
</HTML>

Above code is actually dead code, because it;s surrounded with <%! and %>.
Trackback 0 Comment 0

Trackback : Cannot send a trackbact to this post.