Posts Under ''

Display specific length string without truncating word in Java

If you want to display substring of text and don’t want to truncate word in a substring, then you can use below method to fulfill your requirement. public static String textSubString(String text, int start, int end){ String str=""; int limit=0; limit=end; if(text.length()!=0 && text!=""){ String substr=text.substring(end,end+1); if(substr!=""){ while(!substr.equals("")){ substr=text.substring(limit,++limit); substr=substr.trim(); } } str=text.substring(start,limit); } return […]

Read more »


Java method similar to nl2br in PHP

Below Java method will work same as PHP function nl2br public static String nl2br( String text){ return text.replaceAll("\n","<br />"); }

Read more »


Directory index forbidden by Options directive

I was going through error log and saw this error in error log file. To solve this problem, In /etc/httpd/conf.d you will see a file entitled welcome.conf It looks like this: <LocationMatch “^/+$”> Options -Indexes ErrorDocument 403 /error/noindex.html </LocationMatch> Change it to this: <LocationMatch “^/+$”> Options Indexes ErrorDocument 403 /error/noindex.html </LocationMatch> Just remove the hyppen(-) […]

Read more »


Make sshd listen to a specific address

In file /etc/ssh/sshd_config, use ListenAddress 192.168.0.1 to make sshd listen to only that address.

Read more »


PHP- session Example

Session support in PHP consists of a way to preserve certain data across subsequent accesses. This enables you to build more customized applications and increase the appeal of your web site. A visitor accessing your web site is assigned a unique id, the so-called session id. This is either stored in a cookie on the […]

Read more »