Example usage for javax.servlet.http HttpServletRequest getParameter

List of usage examples for javax.servlet.http HttpServletRequest getParameter

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletRequest getParameter.

Prototype

public String getParameter(String name);

Source Link

Document

Returns the value of a request parameter as a String, or null if the parameter does not exist.

Usage

From source file:co.edu.UNal.ArquitecturaDeSoftware.Bienestar.Vista.App.Usuario.Read.java

protected static void registrarATallerDocenteByDoc(HttpServletRequest request, HttpServletResponse response)
        throws IOException {
    ArrayList r = CtrlUsuario.registrarATallerDocenteByDoc(request.getParameter("1"),
            Integer.parseInt(request.getParameter("2"))); // parameter 1: documentoDocente param2: idTaller

    response.setContentType("application/json;charset=UTF-8");
    PrintWriter out = response.getWriter();
    if (r.get(0) == "error") {
        JSONObject obj = new JSONObject();
        obj.put("isError", true);
        obj.put("errorDescrip", r.get(1));
        out.print(obj);/*  ww  w .  j  a  v  a2s  . c om*/
    } else if (r.get(0) == "isExitoso") {
        JSONObject obj = new JSONObject();
        obj.put("Exitoso", true);
        out.print(obj);
    } else {
        Util.errordeRespuesta(r, out);
    }
}

From source file:com.google.appengine.tools.mapreduce.MapReduceServletTest.java

private static HttpServletRequest createMockControllerRequest(int sliceNumber, JobID jobId) {
    HttpServletRequest request = createMockRequest(MapReduceServlet.CONTROLLER_PATH, true, false);
    expect(request.getParameter(AppEngineJobContext.SLICE_NUMBER_PARAMETER_NAME)).andReturn("" + sliceNumber)
            .anyTimes();/*from  w  w w  .  jav a 2  s  .  c o m*/
    expect(request.getParameter(AppEngineJobContext.JOB_ID_PARAMETER_NAME)).andReturn("" + jobId).anyTimes();
    return request;
}

From source file:controllers.IndexServlet.java

private static void Convert(HttpServletRequest request, HttpServletResponse response, PrintWriter writer) {
    response.setContentType("text/plain");

    try {/* w w  w. ja  v a 2  s  .  co  m*/
        String fileName = request.getParameter("filename");
        String fileUri = DocumentManager.GetFileUri(fileName);
        String fileExt = FileUtility.GetFileExtension(fileName);
        FileType fileType = FileUtility.GetFileType(fileName);
        String internalFileExt = DocumentManager.GetInternalExtension(fileType);

        if (DocumentManager.GetConvertExts().contains(fileExt)) {
            String key = ServiceConverter.GenerateRevisionId(fileUri);

            Pair<Integer, String> res = ServiceConverter.GetConvertedUri(fileUri, fileExt, internalFileExt, key,
                    true);

            int result = res.getKey();
            String newFileUri = res.getValue();

            if (result != 100) {
                writer.write("{ \"step\" : \"" + result + "\", \"filename\" : \"" + fileName + "\"}");
                return;
            }

            String correctName = DocumentManager
                    .GetCorrectName(FileUtility.GetFileNameWithoutExtension(fileName) + internalFileExt);

            URL url = new URL(newFileUri);
            java.net.HttpURLConnection connection = (java.net.HttpURLConnection) url.openConnection();
            InputStream stream = connection.getInputStream();

            if (stream == null) {
                throw new Exception("Stream is null");
            }

            File convertedFile = new File(DocumentManager.StoragePath(correctName, null));
            try (FileOutputStream out = new FileOutputStream(convertedFile)) {
                int read;
                final byte[] bytes = new byte[1024];
                while ((read = stream.read(bytes)) != -1) {
                    out.write(bytes, 0, read);
                }

                out.flush();
            }

            connection.disconnect();

            //remove source file ?
            //File sourceFile = new File(DocumentManager.StoragePath(fileName, null));
            //sourceFile.delete();

            fileName = correctName;
        }

        writer.write("{ \"filename\" : \"" + fileName + "\"}");

    } catch (Exception ex) {
        writer.write("{ \"error\": \"" + ex.getMessage() + "\"}");
    }
}

From source file:org.wuspba.ctams.ui.server.DataUtils.java

protected static CTAMSDocument getBand(HttpServletRequest request) {

    Band band = new Band();
    band.setId(request.getParameter("id"));
    band.setName(request.getParameter("name"));
    band.setAddress(request.getParameter("address"));
    band.setCity(request.getParameter("city"));
    band.setState(request.getParameter("state"));
    band.setZip(request.getParameter("zip"));
    band.setCountry(request.getParameter("country"));
    band.setTelephone(request.getParameter("telephone"));
    band.setUrl(request.getParameter("url"));
    band.setEmail(request.getParameter("email"));
    band.setGrade(Grade.valueOf(request.getParameter("grade")));
    band.setBranch(Branch.valueOf(request.getParameter("branch")));
    band.setType(BandType.valueOf(request.getParameter("type")));
    band.setDissolved(Boolean.valueOf(request.getParameter("dissolved")));

    CTAMSDocument doc = new CTAMSDocument();
    doc.getBands().add(band);/*w w  w.ja  v a  2  s.  com*/

    return doc;
}

From source file:de.knurt.fam.template.util.ContactDetailsRequestHandler.java

/**
 * return the user that is in the request or null, if no user found.
 * //from  w  w  w  .  j  ava 2s .c o m
 * @param rq
 *            request got
 * @return the user that is in the request or null, if no user found.
 */
public static User getUserOfRequest(HttpServletRequest rq) {
    User result = null;
    Integer user_id = null;
    try {
        user_id = Integer.parseInt(rq.getParameter("user_id"));
    } catch (NumberFormatException e) {
    }
    if (user_id != null) {
        User example = UserFactory.getInstance().blank();
        example.setId(user_id);
        result = FamDaoProxy.userDao().getOneLike(example);
    }
    return result;
}

From source file:org.wuspba.ctams.ui.server.DataUtils.java

protected static CTAMSDocument getVenue(HttpServletRequest request) {

    Venue venue = new Venue();
    venue.setId(request.getParameter("id"));
    venue.setName(request.getParameter("name"));
    venue.setSponsor(request.getParameter("sponsor"));
    venue.setAddress(request.getParameter("address"));
    venue.setCity(request.getParameter("city"));
    venue.setState(request.getParameter("state"));
    venue.setZip(request.getParameter("zip"));
    venue.setCountry(request.getParameter("country"));
    venue.setPhone(request.getParameter("phone"));
    venue.setUrl(request.getParameter("url"));
    venue.setEmail(request.getParameter("email"));
    venue.setBranch(Branch.valueOf(request.getParameter("branch")));
    venue.setBandContest(Boolean.valueOf(request.getParameter("bandContest")));
    venue.setSoloContest(Boolean.valueOf(request.getParameter("soloContest")));

    CTAMSDocument doc = new CTAMSDocument();
    doc.getVenues().add(venue);//  w  w  w .j  a  v  a2 s .com

    return doc;
}

From source file:com.feilong.taglib.display.pager.PagerTag.java

/**
 * debugNotParseVM=true??? ??vm?,./*from  w w w .  jav a 2s. c o  m*/
 *
 * @param request
 *            the request
 * @return the debug is not parse vm
 * @since 1.7.2
 */
private static boolean getDebugIsNotParseVM(HttpServletRequest request) {
    // debugNotParseVM=true??? ??vm?,
    String parameter = request.getParameter(PagerConstants.DEFAULT_PARAM_DEBUG_NOT_PARSEVM);
    return PagerConstants.DEFAULT_PARAM_DEBUG_NOT_PARSEVM_VALUE.equals(parameter);
}

From source file:org.carewebframework.security.spring.DesktopSecurityContextRepository.java

/**
 * Returns the desktop-specific (if desktop id available) or session-specific context key from
 * the request.//from   www. j av a 2s . co  m
 * 
 * @param request The request object.
 * @return The context key (never null).
 */
private static String getDesktopContextKey(HttpServletRequest request) {
    String key = getDesktopContextKey(request.getParameter("dtid"));
    return key == null ? CONTEXT_KEY : key;
}

From source file:co.edu.UNal.ArquitecturaDeSoftware.Bienestar.Vista.App.Usuario.Read.java

protected static void quitarDocenteTaller(HttpServletRequest request, HttpServletResponse response)
        throws IOException {
    ArrayList r = CtrlUsuario.abandonarTallerDocente(Integer.parseInt(request.getParameter("1")),
            Integer.parseInt(request.getParameter("2"))); //1. idUsuario, 2. idEvento

    response.setContentType("application/json;charset=UTF-8");
    PrintWriter out = response.getWriter();
    if (r.get(0) == "error") {
        JSONObject obj = new JSONObject();
        obj.put("isError", true);
        obj.put("errorDescrip", r.get(1));
        out.print(obj);//from www .  j  a va  2s . c  o  m
    } else if (r.get(0) == "isExitoso") {
        JSONObject obj = new JSONObject();
        obj.put("Exitoso", true);
        out.print(obj);
    } else {
        Util.errordeRespuesta(r, out);
    }
}

From source file:co.edu.UNal.ArquitecturaDeSoftware.Bienestar.Vista.App.Usuario.Read.java

protected static void quitarUsuarioConvocatoria(HttpServletRequest request, HttpServletResponse response)
        throws IOException {
    ArrayList r = CtrlUsuario.abandonarConvocatoria(Integer.parseInt(request.getParameter("1")), //1. idUsuario
            Integer.parseInt(request.getParameter("2"))// 2. idEvento
    );//from w  w  w . j a v  a  2  s.co  m

    response.setContentType("application/json;charset=UTF-8");
    PrintWriter out = response.getWriter();
    if (r.get(0) == "error") {
        JSONObject obj = new JSONObject();
        obj.put("isError", true);
        obj.put("errorDescrip", r.get(1));
        out.print(obj);
    } else if (r.get(0) == "isExitoso") {
        JSONObject obj = new JSONObject();
        obj.put("Exitoso", true);
        out.print(obj);
    } else {
        Util.errordeRespuesta(r, out);
    }
}