How To

1.  How to configure database in Liferay?


Liferay database configuration is done in In Liferay tomcat bundle the location of this file is tomcat-7.0.42\webapps\ROOT\WEB-INF\classes

If the file is not there then you can create it. For MySQL database configuration put the below code in file.


In the above

lportal620 is the database Name
root is the User Name
jdbc.default.password= Is the password which is empty. Consider your password is sa then it should be
jdbc:mysql://localhost/lportal620 is the database URL


2.  How to add JSP page in theme?


Create the jsp page under the "docroot" folder of your theme. Say you have created /jsp/view.jsp under your docroot folder then you can include the view.jsp in any one of vm file as follows

     $theme.include($themeServletContext, "/jsp/view.jsp")


3.  How to read properties file in portlet?


There are 2 ways you can read properties file in liferay portlet.
A) Just create under src folder of your portlet and write some key value inside your file. You can read the key as bellow...

    String value = PortletProps.get("key");

B) You can load your own properties file with your custom name file. Create a class with the following  name

import java.util.Properties;

public class PropsUtil {
    private static Properties props = null;
    private  PropsUtil(){
        ClassLoader classLoader = getClass().getClassLoader();
        InputStream is = classLoader.getResourceAsStream("resource/");
        props = new Properties();
        try {
        } catch (IOException e) {
    private static synchronized Properties getProperty(){
        if(props == null){
            new PropsUtil();
            return PropsUtil.props;
            return props;
    public static String get(String key){
        return getProperty().getProperty(key);

Here resource/ is your properties file that's under src\resource folder. You can get the key value as bellow
String value = PropsUtil.get("key");

7 Responses so far.

  1. Hi,

    I am creating a theme for LR 6.2 and now I want dummy or sample content to check whether my theme is working properly or not.

    Do you have any idea? I don't want to force user to create web content or portlet for theme testing only.

  2. Mahesh says:

    Realy its a good article..You have clarified so many things which i have been searching...good job...

  3. Alok Halder says:

    This is good site

  4. vamsi alla says:

    This is good site

  5. raghu says:

    Hamidul- Your articles are good read. kudos!.
    I was looking to import header and footer from an existing web page. Is it possible to do this without loosing the functionality of the existing page. Is Velocity required in this case.

  6. Mahesh says:

    HI Hamidul,
    Can you post an article how to create login.jsp hook in liferay7?

Leave a Reply

Your email address will not be published. Required fields are marked *

Are you human? * Time limit is exhausted. Please reload CAPTCHA.

%d bloggers like this:

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.