All Downloads are FREE. Search and download functionalities are using the official Maven repository.

at.spardat.xma.boot.servlet.XmaLauncherServlet Maven / Gradle / Ivy

/*******************************************************************************
 * Copyright (c) 2003, 2007 s IT Solutions AT Spardat GmbH .
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     s IT Solutions AT Spardat GmbH - initial API and implementation
 *******************************************************************************/

/*
 * Created on 02.09.2003
 */
package at.spardat.xma.boot.servlet;

import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Enumeration;

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

/**
 * @author S2267
 *
 * To change the template for this generated type comment go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
public class XmaLauncherServlet extends HttpServlet {

    static final private String CONTENT_TYPE = "application/x-xmalauncher; charset=UTF-8";

     //static final private String CONTENT_TYPE = "application/x-xmalauncher";
    public void doGet(HttpServletRequest req, HttpServletResponse response)
        throws ServletException, IOException {

  // Set content type and create a new PrintWriter to write the data in UTF-8*/
         response.setContentType(CONTENT_TYPE);
        //PrintWriter out = response.getWriter();
          PrintWriter out = new PrintWriter(new OutputStreamWriter(response.getOutputStream(), "UTF8"), true);
          out.println("[Component]");
          out.print("name=");
          String url=req.getRequestURL().toString();

          int index = url.lastIndexOf(".");
          if (index >=0){
             out.print(url.substring(0, index));
          }

         out.println();
         if (req.getQueryString()!=null){
          out.println();
          out.println("[Params]");
          Enumeration params = req.getParameterNames();
          while (params.hasMoreElements()) {
            String name = (String) params.nextElement();
            String values[] = req.getParameterValues(name);
            if (values != null) {
              for (int i = 0; i < values.length; i++) {
                 out.print(name);
                 out.print("=");
                 out.print(values[i]);
                 out.println();
              }
            }
          }
         }
         out.close();
     }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy