Setting up Apache Tomcat 7.0 to work with NetBeans IDE 7.0.1

Go to http://tomcat.apache.org/ to download the latest Tomcat server zip file. Install it in your computer C:\ drive.
Open your software NetBeans IDE, click on Tools menu, select Servers. You can remove GlassFish which is the default server and add the Tomcat. If you already used the port 8080 for PHP localhost, you should use port 8081 for Tomcat and Shutdown port is 8006.

Important step: You must define user role as “manager-script” in Tomcat70\conf\tomcat-users.xml in order to run in NetBeans. Add these 2 lines inside <tomcat-users> block.

<role rolename=”tomcat”/>
<user username=”tomcat” password=”tomcat” roles=”manager-script” />

You’re done! Now you can run or debug jsp pages in NetBeans. Hope this helps some of you who are Java beginners.

What is the difference between <%@ include file="xyz.jsp" %> and in JSP?

The <%@include file=”xyz.jsp” %> or <%@include file=”xyz.html” %> directive pulls in the text of the included file and compiling it as if it were part of the including file. The included file can be any type (including HTML or text).

The tag compiles the file as a separate JSP file, and embeds a call to it in the compiled JSP. The include action is executed at request time as opposed to translation time. Thus instead of the content of the include file being included in the calling JSP, the output of the JSP is included or passed to the JSPWriter of the calling page. This allows us to include both static and dynamic content into a JSP page. Using the jsp action also allows us to explicitly pass parameters to the included page.

<jsp:include page=”/index_extra.jsp”>
<jsp:param name=”productid” value=”SKU99999″ />
</jsp:include>

How to set Tomcat Server Port in Java EE

If you have Apache server that running on Port 8080 as localhost, Java EE doesn’t allow you to debug or run your jsp app thru this port again using Tomcat Server. So what will you do?
Open Java EE and specify any java web project. At the bottom of the page, click on “Servers” tab. Double click on the defined Tomcat server (mine is 6.0), it’ll take you to the Overview page. Here you can change the Port from 8080 to 8081 on the HTTP/1.1. Do not change Tomcat Admin Port. You’re done! I include here the screenshot of the Servers tab in my Java EE.
Set Tomcat Server Port in Java EE

Change the background color of a row using OnMouseOver function

When displaying data in multiple rows and multiple columns, you want your customer to be able to view data through all the columns of a specific row easily. Well, there’s a onMouseOver function in JavaScript that lets you change the background color of the entire row in a table when user places mouse over that row.

Usage:

<table>
<tr>
<td height="18">First name</td>
<td height="18">Last name</td>
<td height="18">Email address</td>
<td height="18">Phone number</td>
</tr>
<tr onmouseover="this.className='change-bg'" onmouseout="this.className='white-bg'" >
<td height="18">Peter</td>
<td height="18">Hug</td>
<td height="18">hisemail@yahoo.com</td>
<td height="18">800-111-0000</td>
</tr>
</table>

In the .css file, add 2 classes and they must be defined with 2 different background colors.

.change-bg{ background: #FFF7D9; }

.white-bg{ background: #ffffff; }

Should or shouldnot use eval() function to evaluates an encrypted PHP source code?

The function is eval ( string $str )

This string $str can be already decrypted from an encrypted string using Hash or bin2hex or base64.

The string passed to eval() function must be valid PHP code and must end with semicolon. You can evaluate a class, a function and a string of multiple lines of php code.

This function returns NULL unless a return statement is called in the code string. Then the value passed to return is returned. eval() returns FALSE if there is a parse error in the code string. The parser will die on the line after the eval() function call if the string is not properly escaping. In order to mix HTML output and PHP codes, you can use a closing PHP tag to leave PHP mode.

Unfortunately this eval() function is not the good way to decrypt your php codes because the pure PHP can be viewed in browser. Some intermediate programmers can easily hack the encrypted codes that use eval() function to execute php.

Note: Because this is a language construct and not a function, it cannot be called using variable functions.

For example: if you write a function like the one below and call it from another file, it won’t work.

function evaluate_this_code($pString){
eval(
$pString);
}
and pass a string to a function call like this:
evaluate_this_code($some_other_string);

It won’t work the way you expected.