Friday, February 14, 2014

Run JSP Programs in Linux

Hello friends, it is observed there are many ways of decorating the websites. Many different languages are integrated with in each other to make the application more reliable as compared to other applicatons. This also is the case with the internet, where people want fast access to their data in a more easy amd convient way.

For this reason JSP is introduced so as to make the web page more interactive then using applets on the web pages. JSP i.e Java Server Pages  which contain normal java code and that can be executed and integrated in to simple html pages and make dynamic html pages.
To run JSP programs on Linux we need a web-server for example Apache Tomcat, a browser and some knowledge of HTML.

Installing Apache Tomcat:

            $ sudo apt-get install tomcat7

Example:  first.jsp

                        First JSP Program
            <h2> Hello World</h2>
            <%= new java.util.Date() %>
            <% out.println(" Hi Dinesh"); %>
                         Copyright &copy;

Create a folder in “/var/lib/tomcat7/webapps/”  where you can save your code so that tomcat can complie and run the code that you are accessing. Command to create the folder is:
            $ sudo mkdir /var/lib/tomcat7/webapps/example

Now save the above file in example folder and open your browser so as to run the program, to run the program. To run the program now type in the address bar the path of the file,
Here localhost specifies that we are running the program remotely and through 8080 port, example is the folder name and first.jsp is the file name.