Tabnine Logo
HttpServletRequest.getParameter
Code IndexAdd Tabnine to your IDE (free)

How to use
getParameter
method
in
javax.servlet.http.HttpServletRequest

Best Java code snippets using javax.servlet.http.HttpServletRequest.getParameter (Showing top 20 results out of 18,540)

Refine searchRefine arrow

  • HttpServletResponse.getWriter
  • HttpServletResponse.setContentType
  • HttpServletRequest.setAttribute
  • PrintWriter.print
  • HttpServletRequest.getSession
  • PrintWriter.println
  • HttpSession.getAttribute
  • HttpServletResponse.sendRedirect
  • HttpSession.setAttribute
origin: stackoverflow.com

 protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  String username = request.getParameter("username");
  String password = request.getParameter("password");
  User user = userService.find(username, password);

  if (user != null) {
    request.getSession().setAttribute("user", user); // Login user.
    response.sendRedirect("home"); // Redirect to home page.
  } else {
    request.setAttribute("message", "Unknown username/password. Please retry."); // Store error message in request scope.
    request.getRequestDispatcher("/WEB-INF/login.jsp").forward(request, response); // Forward to JSP page to redisplay login form with error.
  }
}
origin: stackoverflow.com

 public class LoginAction implements Action {

  public String execute(HttpServletRequest request, HttpServletResponse response) throws Exception {
    String username = request.getParameter("username");
    String password = request.getParameter("password");
    User user = userDAO.find(username, password);

    if (user != null) {
      request.getSession().setAttribute("user", user); // Login user.
      return "home"; // Redirect to home page.
    }
    else {
      request.setAttribute("error", "Unknown username/password. Please retry."); // Store error message in request scope.
      return "login"; // Go back to redisplay login form with error.
    }
  }

}
origin: stackoverflow.com

 @WebServlet("/product")
public class ProductServlet extends HttpServlet {

  @EJB
  private ProductService productService;

  @Override
  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    Product product = productService.find(request.getParameter("id"));
    request.setAttribute("product", product); // Will be available as ${product} in JSP
    request.getRequestDispatcher("/WEB-INF/product.jsp").forward(request, response);
  }

}
origin: spotbugs/spotbugs

@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException {
  String id = request.getParameter("id");
  PrintWriter out = response.getWriter();
  response.setContentType("text/plain");
  out.println("Id is " + id);
}
origin: Codecademy/EventHub

 @Override
 public synchronized void execute(final HttpServletRequest request,
   final HttpServletResponse response) throws IOException {
  String prefix = request.getParameter("prefix");
  prefix = (prefix == null ? "" : prefix);
  List<String> values = eventHub.getEventValues(
    request.getParameter("event_type"),
    request.getParameter("event_key"),
    prefix);
  response.getWriter().println(gson.toJson(values));
 }
}
origin: BroadleafCommerce/BroadleafCommerce

private Long lookupSandboxId(HttpServletRequest request) {
  String sandboxIdStr = request.getParameter(SANDBOX_ID_VAR);
  Long sandboxId = null;
  if (sandboxIdStr != null) {
    try {
      sandboxId = Long.valueOf(sandboxIdStr);
      if (LOG.isTraceEnabled()) {
        LOG.trace("SandboxId found on request " + sandboxId);
      }
    } catch (NumberFormatException nfe) {
      LOG.warn("blcSandboxId parameter could not be converted into a Long", nfe);
    }
  }
  if (sandboxId == null) {
    // check the session
    HttpSession session = request.getSession(false);
    if (session != null) {
      sandboxId = (Long) session.getAttribute(SANDBOX_ID_VAR);
      if (LOG.isTraceEnabled()) {
        if (sandboxId != null) {
          LOG.trace("SandboxId found in session " + sandboxId);
        }
      }
    }
  } else {
    HttpSession session = request.getSession();
    session.setAttribute(SANDBOX_ID_VAR, sandboxId);
  }
  return sandboxId;
}
origin: nutzam/nutz

public void render(HttpServletRequest req, HttpServletResponse resp, Object obj)
    throws IOException {
  if (resp.getContentType() == null)
    if (jsonp)
      resp.setContentType(JSONP_CT);
    else
      resp.setContentType(CT);
  Writer writer = resp.getWriter();
  if (jsonp)
    writer.write(req.getParameter(jsonpParam == null ? "callback" : jsonpParam) + "(");
  Mvcs.write(resp, writer, null == obj ? data : obj, format);
  if (jsonp)
    writer.write(");");
}
origin: alibaba/druid

String usernameParam = request.getParameter(PARAM_NAME_USERNAME);
String passwordParam = request.getParameter(PARAM_NAME_PASSWORD);
if (username.equals(usernameParam) && password.equals(passwordParam)) {
  request.getSession().setAttribute(SESSION_USER_KEY, username);
  response.getWriter().print("success");
} else {
  response.getWriter().print("error");
|| path.startsWith("/img"))) {
if (contextPath.equals("") || contextPath.equals("/")) {
  response.sendRedirect("/druid/login.html");
} else {
  if ("".equals(path)) {
    response.sendRedirect("druid/login.html");
  } else {
    response.sendRedirect("login.html");
  fullUrl += "?" + request.getQueryString();
response.getWriter().print(process(fullUrl));
return;
origin: magro/memcached-session-manager

/**
 * {@inheritDoc}
 */
@Override
protected void doPost( final HttpServletRequest request, final HttpServletResponse response ) throws ServletException, IOException {
  LOG.info( "invoked" );
  final HttpSession session = request.getSession();
  waitIfRequested( request );
  final PrintWriter out = response.getWriter();
  out.println( "OK: " + session.getId() );
  @SuppressWarnings( "unchecked" )
  final Enumeration<String> names = request.getParameterNames();
  while ( names.hasMoreElements() ) {
    final String name = names.nextElement();
    final String value = request.getParameter( name );
    session.setAttribute( name, value );
  }
}
origin: DeemOpen/zkui

  @Override
  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    logger.debug("Export Get Action!");
    try {
      Properties globalProps = (Properties) this.getServletContext().getAttribute("globalProps");
      String zkServer = globalProps.getProperty("zkServer");
      String[] zkServerLst = zkServer.split(",");

      String authRole = (String) request.getSession().getAttribute("authRole");
      if (authRole == null) {
        authRole = ZooKeeperUtil.ROLE_USER;
      }
      String zkPath = request.getParameter("zkPath");
      StringBuilder output = new StringBuilder();
      output.append("#App Config Dashboard (ACD) dump created on :").append(new Date()).append("\n");
      Set<LeafBean> leaves = ZooKeeperUtil.INSTANCE.exportTree(zkPath, ServletUtil.INSTANCE.getZookeeper(request, response, zkServerLst[0], globalProps), authRole);
      for (LeafBean leaf : leaves) {
        output.append(leaf.getPath()).append('=').append(leaf.getName()).append('=').append(ServletUtil.INSTANCE.externalizeNodeValue(leaf.getValue())).append('\n');
      }// for all leaves
      response.setContentType("text/plain;charset=UTF-8");
      try (PrintWriter out = response.getWriter()) {
        out.write(output.toString());
      }

    } catch (InterruptedException | KeeperException ex) {
      logger.error(Arrays.toString(ex.getStackTrace()));
      ServletUtil.INSTANCE.renderError(request, response, ex.getMessage());
    }
  }
}
origin: javaee-samples/javaee7-samples

@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  request.setAttribute("jaccTest", "true");
  try {
    HttpServletRequest requestFromPolicy = (HttpServletRequest) PolicyContext.getContext("javax.servlet.http.HttpServletRequest");
    if (requestFromPolicy != null) {
      response.getWriter().print("Obtained request from context.");
      if ("true".equals(requestFromPolicy.getAttribute("jaccTest"))) {
        response.getWriter().print("Attribute present in request from context.");
      }
      if ("true".equals(requestFromPolicy.getParameter("jacc_test"))) {
        response.getWriter().print("Request parameter present in request from context.");
      }
    }
  } catch (PolicyContextException e) {
    e.printStackTrace(response.getWriter());
  }
}
origin: gocd/gocd

  public boolean verify(HttpServletRequest request) {
    String postedToken = request.getParameter(TOKEN);
    String expectedToken = (String) request.getSession().getAttribute(TOKEN);
    return !StringUtils.isBlank(postedToken) && !StringUtils.isBlank(expectedToken) && postedToken.equals(expectedToken);
  }
}
origin: ehcache/ehcache3

 @Override
 protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException {
  String peepText = req.getParameter("peep");

  try {

   PeeperServletContextListener.DATA_STORE.addPeep(peepText);
   resp.sendRedirect("peep");

  } catch (Exception e) {
   throw new ServletException("Error saving peep", e);
  }
 }
}
origin: stanfordnlp/CoreNLP

private void addResults(HttpServletRequest request,
            HttpServletResponse response) throws IOException {
 String input = request.getParameter("input");
 if (input == null) {
  return;
 PrintWriter out = response.getWriter();
 if (input.length() > MAXIMUM_QUERY_LENGTH) {
  out.print("This query is too long.  If you want to run very long queries, please download and use our <a href=\"http://nlp.stanford.edu/software/CRF-NER.html\">publicly released distribution</a>.");
  return;
 String outputFormat = request.getParameter("outputFormat");
 if (outputFormat == null || outputFormat.trim().isEmpty()) {
  outputFormat = this.format;
 String preserveSpacingStr = request.getParameter("preserveSpacing");
 if (preserveSpacingStr == null || preserveSpacingStr.trim().isEmpty()) {
  preserveSpacing = this.spacing;
 String classifier = request.getParameter("classifier");
 if (classifier == null || classifier.trim().isEmpty()) {
  classifier = this.defaultClassifier;
  outputHighlighting(out, ners.get(classifier), input);
 } else {
  out.print(StringEscapeUtils.escapeHtml4(ners.get(classifier).classifyToString(input, outputFormat, preserveSpacing)));
origin: DeemOpen/zkui

String action = request.getParameter("action");
String currentPath = request.getParameter("currentPath");
String displayPath = request.getParameter("displayPath");
String newProperty = request.getParameter("newProperty");
String newValue = request.getParameter("newValue");
String newNode = request.getParameter("newNode");
String searchStr = request.getParameter("searchStr").trim();
String authRole = (String) request.getSession().getAttribute("authRole");
      request.getSession().setAttribute("flashMsg", "Node created!");
      dao.insertHistory((String) request.getSession().getAttribute("authName"), request.getRemoteAddr(), "Creating node: " + currentPath + newNode);
    response.sendRedirect("/home?zkPath=" + displayPath);
    break;
  case "Save Property":
      request.getSession().setAttribute("flashMsg", "Property Saved!");
      if (ZooKeeperUtil.INSTANCE.checkIfPwdField(newProperty)) {
        newValue = ZooKeeperUtil.INSTANCE.SOPA_PIPA;
      dao.insertHistory((String) request.getSession().getAttribute("authName"), request.getRemoteAddr(), "Saving Property: " + currentPath + "," + newProperty + "=" + newValue);
    response.sendRedirect("/home?zkPath=" + displayPath);
    break;
  case "Update Property":
      dao.insertHistory((String) request.getSession().getAttribute("authName"), request.getRemoteAddr(), "Updating Property: " + currentPath + "," + newProperty + "=" + newValue);
origin: apache/hbase

 @Override
 public void doGet(HttpServletRequest request,
          HttpServletResponse response
          ) throws ServletException, IOException {
  PrintWriter out = response.getWriter();
  SortedSet<String> sortedKeys = new TreeSet<>();
  Enumeration<String> keys = request.getParameterNames();
  while(keys.hasMoreElements()) {
   sortedKeys.add(keys.nextElement());
  }
  for(String key: sortedKeys) {
   out.print(key);
   out.print(':');
   out.print(request.getParameter(key));
   out.print('\n');
  }
  out.close();
 }
}
origin: jenkinsci/jenkins

/**
 * @see org.acegisecurity.ui.AbstractProcessingFilter#determineFailureUrl(javax.servlet.http.HttpServletRequest, org.acegisecurity.AuthenticationException)
 */
@Override
protected String determineFailureUrl(HttpServletRequest request, AuthenticationException failed) {
  Properties excMap = getExceptionMappings();
  String failedClassName = failed.getClass().getName();
  String whereFrom = request.getParameter("from");
  request.getSession().setAttribute("from", whereFrom);
  return excMap.getProperty(failedClassName, getAuthenticationFailureUrl());
}
origin: javaee-samples/javaee7-samples

@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  response.getWriter().write("Public resource invoked\n");
  if (request.getParameter("doLogout") != null) {
    request.logout();
  }
}
origin: com.h2database/h2

String file = req.getPathInfo();
if (file == null) {
  resp.sendRedirect(req.getRequestURI() + "/");
  return;
} else if (file.startsWith("/")) {
while (en.hasMoreElements()) {
  String name = en.nextElement().toString();
  String value = req.getParameter(name);
  attributes.put(name, value);
    bytes = page.getBytes(StandardCharsets.UTF_8);
  resp.setContentType(mimeType);
  if (!cache) {
    resp.setHeader("Cache-Control", "no-cache");
origin: oblac/jodd

/**
 * Checks if {@link jodd.servlet.tag.CsrfTokenTag CSRF token} is valid.
 * Returns <code>false</code> if token was requested, but not found.
 * Otherwise, it returns <code>true</code>.
 */
@SuppressWarnings({"unchecked"})
public static boolean checkCsrfToken(final HttpServletRequest request, final String tokenName) {
  String tokenValue = request.getParameter(tokenName);
  return checkCsrfToken(request.getSession(), tokenValue);
}
javax.servlet.httpHttpServletRequestgetParameter

Popular methods of HttpServletRequest

  • getHeader
    Returns the value of the specified request header as a String. If the request did not include a head
  • getRequestURI
    Returns the part of this request's URL from the protocol name up to the query string in the first li
  • getSession
    Returns the current HttpSession associated with this request or, if there is no current session and
  • getMethod
    Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT
  • getAttribute
  • getContextPath
    Returns the portion of the request URI that indicates the context of the request. The context path a
  • getQueryString
    Returns the query string that is contained in the request URL after the path. This method returns nu
  • setAttribute
  • getPathInfo
    Returns any extra path information associated with the URL the client sent when it made this request
  • getRequestURL
    Reconstructs the URL the client used to make the request. The returned URL contains a protocol, serv
  • getRemoteAddr
  • getServletPath
    Returns the part of this request's URL that calls the servlet. This path starts with a "/" character
  • getRemoteAddr,
  • getServletPath,
  • getInputStream,
  • getParameterMap,
  • getCookies,
  • getServerName,
  • getHeaderNames,
  • getScheme,
  • getServerPort

Popular in Java

  • Making http requests using okhttp
  • setContentView (Activity)
  • runOnUiThread (Activity)
  • requestLocationUpdates (LocationManager)
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • BigInteger (java.math)
    An immutable arbitrary-precision signed integer.FAST CRYPTOGRAPHY This implementation is efficient f
  • Dictionary (java.util)
    Note: Do not use this class since it is obsolete. Please use the Map interface for new implementatio
  • HashSet (java.util)
    HashSet is an implementation of a Set. All optional operations (adding and removing) are supported.
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • LoggerFactory (org.slf4j)
    The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for lo
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now