<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<c:if test="${fn:length(string)>0}">
...
</c:if>
Wednesday, November 21, 2012
JSP JSTL String length
Saturday, November 3, 2012
Get The Current Working Directory In Java
package com.javaee.insight;
public class Main {
public static void main(String args[]) {
String workingDir = System.getProperty("user.dir");
System.out.println("Current working directory : " + workingDir);
}
}
Setting up ActiveMQ with Tomcat 7
Step 1. Place the activemq-all-5.7.0.jar in [TOMCAT_HOME]/lib directory
Step 2. Open the [TOMCAT_ROOT]/conf/context.xml file and add the below resource to the Context.
Step 2. Open the [TOMCAT_ROOT]/conf/context.xml file and add the below resource to the Context.
<Context>
<Resource name="jms/ConnectionFactory"
auth="Container"
type="org.apache.activemq.ActiveMQConnectionFactory"
description="JMS Connection Factory"
factory="org.apache.activemq.jndi.JNDIReferenceFactory"
brokerURL="tcp://localhost:61616"
brokerName="LocalActiveMQBroker"/>
<Resource
name="jms/queue/Queue"
auth="Container"
type="org.apache.activemq.command.ActiveMQQueue"
description="my Queue"
factory="org.apache.activemq.jndi.JNDIReferenceFactory"
physicalName="APP.QUEUE"/>
</Context>
Step 3. Add the JNDI in your java code.
InitialContext initCtx = new InitialContext();
Context envContext = (Context) initCtx.lookup("java:comp/env");
ConnectionFactory connectionFactory = (ConnectionFactory) envContext.lookup("jms/ConnectionFactory");
Connection connection = connectionFactory.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination destination = session.createQueue("jms/queue/Queue");
MessageProducer producer = session.createProducer(destination);
TextMessage msg = session.createTextMessage();
msg.setText("Message sent");
producer.send(msg);
Subscribe to:
Comments (Atom)