Java Code Examples for javax.servlet.http.HttpServletRequest.getIntHeader()

The following are Jave code examples for showing how to use getIntHeader() of the javax.servlet.http.HttpServletRequest class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: iotplatform   File: BaseController.java   View Source Code Vote up 7 votes
protected String constructBaseUrl(HttpServletRequest request) {
  String scheme = request.getScheme();
  if (request.getHeader("x-forwarded-proto") != null) {
    scheme = request.getHeader("x-forwarded-proto");
  }
  int serverPort = request.getServerPort();
  if (request.getHeader("x-forwarded-port") != null) {
    try {
      serverPort = request.getIntHeader("x-forwarded-port");
    } catch (NumberFormatException e) {
    }
  }

  String baseUrl = String.format("%s://%s:%d", scheme, request.getServerName(), serverPort);
  return baseUrl;
}
 
Example 2
Project: parabuild-ci   File: StatelessTest.java   View Source Code Vote up 6 votes
/**
 * Returns a resource object as a result of a get request.
 **/
protected void doPost( HttpServletRequest req, HttpServletResponse resp ) throws ServletException, IOException {
    int length = req.getIntHeader( "Content-length" );
    String contentType = req.getHeader( "Content-type" );
    resp.setContentType( contentType );

    InputStreamReader isr = new InputStreamReader( req.getInputStream() );
    BufferedReader br = new BufferedReader( isr );
    resp.getWriter().print( length );

    String line = br.readLine();
    while (line != null) {
        resp.getWriter().print( "\n" );
        resp.getWriter().print( line );
        line = br.readLine();
    }
    resp.getWriter().flush();
    resp.getWriter().close();
}
 
Example 3
Project: Equella   File: WebdavServlet.java   View Source Code Vote up 5 votes
private int getRequestedDepth(HttpServletRequest req)
{
	// Request has a depth value which describes how many levels
	// of propeties need to be returned. The default is INFINITY, but
	// usually it is only 1.
	try
	{
		return req.getIntHeader("Depth");
	}
	catch( Exception e )
	{
		// Depth = Infinity
		return Integer.MAX_VALUE;
	}
}
 
Example 4
Project: Storage-System   File: DefaultController.java   View Source Code Vote up 5 votes
@RequestMapping(value = "/addItem", method = RequestMethod.POST)
public String addItem(ModelMap map, HttpServletRequest request) {

    int id = request.getIntHeader("ID");
    String name = request.getParameter("name");
    String dop = request.getParameter("dop");
    float price = Float.parseFloat(request.getParameter("price"));
    String notes = request.getParameter("notes");

      ItemCreation i = new ItemCreation(id, name, dop, price, notes);
      dao.addItem(i);
      
      return "addItem";
}