|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Using Servlet for MQSeries |
« View previous topic :: View next topic » |
Author |
Message
|
chanchalmalik |
Posted: Tue Mar 16, 2004 7:00 am Post subject: Using Servlet for MQSeries |
|
|
Newbie
Joined: 16 Mar 2004 Posts: 3
|
Hey,
I am passing user name and password from a login HTML page to a Servlet which is creating a MQseries message from this information.After adding MQSeries code,I am not able to invoke this Servlet.Please let me know where I am wrong by looking at the code.Its very small example.Please help me.
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import com.ibm.mq.*;
import java.util.*;
public class MQSample11 extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<HTML>");
out.println("<HEAD><TITLE>Simple Servlet</TITLE>");
out.println("</HEAD>");
out.println("<BODY>");
out.println("<H1>Sample MQ Servlet Test</H1>");
try
{
response.setContentType("text/html");
String tempAddress = "Input information is";
Enumeration enum = request.getParameterNames();
while (enum.hasMoreElements())
{
String name = (String) enum.nextElement();
String values = request.getParameter(name);
if(values != null)
{
tempAddress = tempAddress + "; " + name + ": " + values;
}
}
out.println(tempAddress);
// out.println("</BODY></HTML>");
MQQueueManager qMgr;
qMgr = new MQQueueManager("QM1");
int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT;
//Specify the queue that we wish to open, and the open options.
MQQueue ncOrderDataQ = qMgr.accessQueue("SYSTEM.DEFAULT.LOCAL.QUEUE",openOptions);
//Define a MQ message
MQMessage customerAddress = new MQMessage();
customerAddress.writeUTF(tempAddress);
//specify the message options
MQPutMessageOptions pmo = new MQPutMessageOptions();
//put the message on the queue
ncOrderDataQ.put(customerAddress, pmo);
//Close the queue
ncOrderDataQ.close();
qMgr.disconnect();
MQQueueManager qMgr1;
qMgr1 = new MQQueueManager("QM1");
int openOptions1 = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT;
//Specify the queue that we wish to open, and the open options.
MQQueue ncOrderUpdateQ = qMgr1.accessQueue("SYSTEM.DEFAULT.LOCAL.QUEUE",openOptions1);
//create a new get the message
MQMessage retrievedMessage = new MQMessage();
retrievedMessage.messageId = MQC.MQMI_NONE;
//set the get message options
MQGetMessageOptions gmo = new MQGetMessageOptions();
//get the message off the queue
ncOrderUpdateQ.get(retrievedMessage, gmo);
//Display the message
String msgText;
msgText = retrievedMessage.readString(retrievedMessage.getMessageLength());
//for NC.UpdateQ
out.println(msgText);
//Close the queue
ncOrderUpdateQ.close();
qMgr1.disconnect();
}
catch(MQException ex)
{
}
out.println("</BODY></HTML>");
}
} |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Mar 16, 2004 7:02 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Please see my response to your question in the other place you posted.
Please do not post the same question twice.
If you post a question in the wrong place, there is a 'delete' (marked with an X) button available for you to delete the message. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|