Providing solution(interview tips) and doing implementation based on Liferay Portal and Java/J2EE technologies.
Tuesday, 20 March 2018
Empty and null check in JSTL JAVA
Difference between empty and null check of JSTL Core tag
< c:if test="${param.name != null}">< /c:if>
The above tag is to check whether parameter name is null or not. If it is not null then it prints out the sentence and it prints nothing if the value is null.
< c:if test="${param.name ne null}">< /c:if>
A test shows that parameter name contains value of ${param.name} via "ne" operator
Above codes are working similarly with the previous codes. We just want to test JSP notation “ne” for not equal function as what “!=” does.
< c:if test="${not empty(param.name)}">< /c:if>
A test shows that parameter name contains value of ${param.name} via empty operator.
Above codes are another feature of JSP notation to check a value whether it is empty or not. It is basically pretty much the same as the second and third tag do. The difference lies on the value null and empty.
So What is the difference between empty and null?
Well, empty is not necessarily be null but null always be empty. Null means that the variable is simply not existed while empty means that the variable is existed and initialized but it contains nothing. Please be careful when dealing with null values as it may cause you the famous NullPointerException.
The above tag is to check whether parameter name is null or not. If it is not null then it prints out the sentence and it prints nothing if the value is null.
< c:if test="${param.name ne null}">< /c:if>
A test shows that parameter name contains value of ${param.name} via "ne" operator
Above codes are working similarly with the previous codes. We just want to test JSP notation “ne” for not equal function as what “!=” does.
< c:if test="${not empty(param.name)}">< /c:if>
A test shows that parameter name contains value of ${param.name} via empty operator.
Above codes are another feature of JSP notation to check a value whether it is empty or not. It is basically pretty much the same as the second and third tag do. The difference lies on the value null and empty.
So What is the difference between empty and null?
Well, empty is not necessarily be null but null always be empty. Null means that the variable is simply not existed while empty means that the variable is existed and initialized but it contains nothing. Please be careful when dealing with null values as it may cause you the famous NullPointerException.
Friday, 16 March 2018
How to Debug INSE Eclipse server or OutSide Eclpise Setting
Add following user variable
CATALINA_BASE: D: \Liferay Developer Studio 1.5\liferay-portal-6.2.10-ee-ga1\tomcat-7.0.25
CATALINA_HOME: D: \Liferay Developer Studio 1.5\liferay-portal-6.2.10-ee-ga1\tomcat-7.0.25
JAVA_HOME: C:\jdk1.7.0_20\bin
3. Go to following path:
D:\Liferay Developer Studio 1.5\liferay-portal-6.1.10-ee-ga1\tomcat-7.0.25\bin
4. Open startup.bat file
5. Add following line on top of this file
set JPDA_ADDRESS=8000
set JPDA_TRANSPORT=dt_socket
6. Chance executable command as below on last of this file(user jpda start to start sever into jpda debug mode on port 8000)
call "%EXECUTABLE%" jpda start %CMD_LINE_ARGS%
Steps to make configuration into eclipse:
1. Open Eclipse
2. Go to Run Menu -> Debug configuration
3. Go to Remote java application on opend box at left side
4. Add project as “your portlet” (select from browse button in connect tab)
5. Select connect type as Standard (socket attach)
6. Set connection property: localhost
7. Set Port:8000
8. Clickon Common Tab
9. Select Debug check box
Now click on Debug to debug remote server on port 8000
CATALINA_BASE: D: \Liferay Developer Studio 1.5\liferay-portal-6.2.10-ee-ga1\tomcat-7.0.25
CATALINA_HOME: D: \Liferay Developer Studio 1.5\liferay-portal-6.2.10-ee-ga1\tomcat-7.0.25
JAVA_HOME: C:\jdk1.7.0_20\bin
3. Go to following path:
D:\Liferay Developer Studio 1.5\liferay-portal-6.1.10-ee-ga1\tomcat-7.0.25\bin
4. Open startup.bat file
5. Add following line on top of this file
set JPDA_ADDRESS=8000
set JPDA_TRANSPORT=dt_socket
6. Chance executable command as below on last of this file(user jpda start to start sever into jpda debug mode on port 8000)
call "%EXECUTABLE%" jpda start %CMD_LINE_ARGS%
Steps to make configuration into eclipse:
1. Open Eclipse
2. Go to Run Menu -> Debug configuration
3. Go to Remote java application on opend box at left side
4. Add project as “your portlet” (select from browse button in connect tab)
5. Select connect type as Standard (socket attach)
6. Set connection property: localhost
7. Set Port:8000
8. Clickon Common Tab
9. Select Debug check box
Now click on Debug to debug remote server on port 8000
Subscribe to:
Posts (Atom)