Showing posts with label jboss. Show all posts
Showing posts with label jboss. Show all posts

Saturday 9 February 2013

Enabling JSTL (JSP Standard Tag Library) in your web application

JSTL is a good to enable tag library while developing Java Server Pages. It speeds up the development and lets you write logical blocks in fewer lines.

The JSTL library to be included to your web application depends on the version of Servlet you are using. The steps mentioned here lets you choose the right JSTL library version and include it to your web application. We continue from the previous post where we built the web application.

Locating Servlet version

  1. Open web.xml file located in WEB-INF folder.
  2. Check the version attribute of web-app tag.
    Here, the version is 2.5.

Downloading JSTL package depending upon the version

Refer this link to know which version you would need to download depending upon your Servlet version. You will find the download link for each version. I downloaded javax.servlet.jsp.jstl-1.2.1.jar as I have 2.5 version.

Using JSTL in your application

  1. Create a lib folder under WEB-INF.

  2. Copy the downloaded jar file into the lib folder.
  3. Include library to your JSPs and start using it. Here I have modified the existing function to use JSTL tag.
    <%@ page language="java" contentType="text/html; charset=UTF-8"
    <%@ taglib uri="" prefix="c"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Hello World</title>
      Object message = request.getAttribute("message");
      if (message == null) {
     <form action="sayHello" method="post">
      <input type="submit" value="Submit" />
      } else {
     <c:if test="${empty message}">
      <form action="sayHello" method="post">
       <input type="submit" value="Submit" />
     <c:if test="${not empty message}">
      <c:out value="${message}" />

Sunday 20 January 2013

Configuring JBoss server on Eclipse

JBoss application server is a server which offers Java Enterprise Edition services to web applications authored in Java language.

Here are the steps to configure JBoss server on Eclipse:

  1. Download JBoss server from here. I have chosen the 4.2.3 version of JBoss server to download.
  2. Extract the downloaded compressed file to a suitable location. I have extracted the file to /opt.
  3. On Eclipse, go to Servers view. If you do not see Servers view, go to Window > Show View > OtherOn the Show View window, choose Server > Servers and click OK.
  4. Click on new server wizard or right-click and choose New > Server.
  5. Choose JBoss > JBoss v4.2 and click Next.
  6. To set the Application Server Directory, click Browse or type the path to the extracted server folder in step 2 and click Next.
  7. Choose address, port, JNDI port and server configuration and click Next. I have left it as default values here.
  8. If you have any web application to be set to run on the server, add them and click Finish. You will find the server being listed in the Servers view.
  9. Double click on the server listed in the Servers view or right-click and choose Open.
  10. The server can be configured in the window opened up. Expand the Timeouts section and modify the Start and Stop values. These are the values in which the server has to start-up or shutdown as monitored by Eclipse. You may need to increase these timings, otherwise you will end up with an error saying server could not be started as displayed below. Once done, save the configuration from File > Save.

  11. Right-click on the server from Servers view and choose Start.
  12. Monitor the Console view to see if the server has started successfully.
  13. Test the server from browser by going to the host name and port configured.