newHelpline: +91-22-26201606 Ext.325/315. +91-22-26201604 Ext.633.
Mobile Seva

How to write Java Servlet for department pull service?

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class DepartmentServlet extends HttpServlet {

	private static final long serialVersionUID = 1L;

	public DepartmentServlet() {
		super();
	}

	/**
	 * Sample Servlet implementation class for Department
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		PrintWriter out = response.getWriter();

		String MobileNo = ESAPI.encoder().encodeForHTML(request.getParameter("mobileNumber"));
		String TimeStamp = ESAPI.encoder().encodeForHTML(request.getParameter("timeStamp"));
		String OperatorName = ESAPI.encoder().encodeForHTML(request.getParameter("operatorName"));
		String Areacode = ESAPI.encoder().encodeForHTML(request.getParameter("areaCode"));
		String Message = ESAPI.encoder().encodeForHTML(request.getParameter("message"));
		String receiverShortCode = ESAPI.encoder().encodeForHTML(request.getParameter("sc"));
		/*
		 * Using the aboce details, write here your department specific business
		 * logic
		 */

		System.out.println("MobileNo==" + MobileNo + "\n" + "TimeStamp==" + TimeStamp + "\n" + "OperatorName=="
				+ OperatorName + "\n" + "AreaCode==" + Areacode + "\n" + "Message==" + Message + "RecieverShortcode"
				+ receiverShortCode);

		if (receiverShortCode != null) {

			if (receiverShortCode.equalsIgnoreCase("9223166166") || OperatorName.equalsIgnoreCase("TATALONGCODE")) {
				// In case of long code kindly send SMS from your end to the
				// user.
				// E.g.:- SMSServices services = new SMSServices();
				// System.out.println(services.sendSingleSMS("USERNAME",
				// "PASSWORD", "Response Message to User", "SENDERID", MobileNo,
				// "Your Department secureKey"));
				// For above example download code from
				// https://mgov.gov.in/msdp_http_javacode.jsp
			}

		}

		out.println("Write here your response message.");
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doGet(request, response);
	}

}