Class WebUtil

java.lang.Object
org.compiere.util.WebUtil

public final class WebUtil extends Object
Servlet Utilities
Version:
$Id: WebUtil.java,v 1.7 2006/09/24 12:11:54 comdivision Exp $
Author:
Jorg Janke
  • Constructor Details

    • WebUtil

      public WebUtil()
  • Method Details

    • createLoginPage

      @Deprecated public static void createLoginPage(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.http.HttpServlet servlet, Properties ctx, String AD_Message) throws javax.servlet.ServletException, IOException
      Deprecated.
      Create Exit Page "Log-off".

      - End Session - Go to start page (e.g. /adempiere/index.html)

      Parameters:
      request - request
      response - response
      servlet - servlet
      ctx - context
      AD_Message - messahe
      Throws:
      javax.servlet.ServletException
      IOException
    • getLoginButton

      @Deprecated public static org.apache.ecs.xhtml.input getLoginButton(Properties ctx)
      Deprecated.
      Create Login Button - replace Window
      Parameters:
      ctx - context
      Returns:
      Button
    • getCookieProprties

      @Deprecated public static Properties getCookieProprties(javax.servlet.http.HttpServletRequest request)
      Deprecated.
      Get Cookie Properties
      Parameters:
      request - request
      Returns:
      Properties
    • getParameter

      public static String getParameter(javax.servlet.http.HttpServletRequest request, String parameter)
      Get String Parameter.
      Parameters:
      request - request
      parameter - parameter
      Returns:
      string or null
    • getParameterAsInt

      public static int getParameterAsInt(javax.servlet.http.HttpServletRequest request, String parameter)
      Get integer Parameter - 0 if not defined.
      Parameters:
      request - request
      parameter - parameter
      Returns:
      int result or 0
    • getParameterAsBD

      public static BigDecimal getParameterAsBD(javax.servlet.http.HttpServletRequest request, String parameter)
      Get numeric Parameter - 0 if not defined
      Parameters:
      request - request
      parameter - parameter
      Returns:
      big decimal result or 0
    • getParameterAsDate

      public static Timestamp getParameterAsDate(javax.servlet.http.HttpServletRequest request, String parameter)
      Get date Parameter - null if not defined. Date portion only
      Parameters:
      request - request
      parameter - parameter
      Returns:
      timestamp result or null
    • getParameterAsDate

      public static Timestamp getParameterAsDate(javax.servlet.http.HttpServletRequest request, String parameter, Language language)
      Get date Parameter - null if not defined. Date portion only
      Parameters:
      request - request
      parameter - parameter
      language - optional language
      Returns:
      timestamp result or null
    • getParameterAsBoolean

      public static boolean getParameterAsBoolean(javax.servlet.http.HttpServletRequest request, String parameter)
      Get boolean Parameter.
      Parameters:
      request - request
      parameter - parameter
      Returns:
      true if found
    • getParameterAsBoolean

      public static boolean getParameterAsBoolean(javax.servlet.http.HttpServletRequest request, String parameter, String expected)
      Get boolean Parameter.
      Parameters:
      request - request
      parameter - parameter
      expected - optional expected value
      Returns:
      true if found and if optional value matches
    • getParamOrNull

      public static String getParamOrNull(javax.servlet.http.HttpServletRequest request, String parameter)
      Get Parameter or Null if empty
      Parameters:
      request - request
      parameter - parameter
      Returns:
      Request Value or null
    • createResponse

      public static void createResponse(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.http.HttpServlet servlet, Properties cookieProperties, WebDoc doc, boolean debug) throws IOException
      Create Standard Response Header with optional Cookie and print document. D:\j2sdk1.4.0\docs\guide\intl\encoding.doc.html
      Parameters:
      request - request
      response - response
      servlet - servlet
      cookieProperties - cookie properties
      doc - doc
      debug - debug
      Throws:
      IOException
    • getClearFrame

      @Deprecated public static org.apache.ecs.xhtml.script getClearFrame(String targetFrame)
      Deprecated.
      Create Java Script to clear Target frame
      Parameters:
      targetFrame - target frame
      Returns:
      Clear Frame Script
    • getForward

      @Deprecated public static HtmlCode getForward(String url, int delaySec)
      Deprecated.
      Return a link and script with new location.
      Parameters:
      url - forward url
      delaySec - delay in seconds (default 3)
      Returns:
      html
    • createForwardPage

      @Deprecated public static void createForwardPage(javax.servlet.http.HttpServletResponse response, String title, String forwardURL, int delaySec) throws javax.servlet.ServletException, IOException
      Deprecated.
      Create Forward Page
      Parameters:
      response - response
      title - page title
      forwardURL - url
      delaySec - delay in seconds (default 3)
      Throws:
      javax.servlet.ServletException
      IOException
    • exists

      public static boolean exists(String test)
      Does Test exist
      Parameters:
      test - string
      Returns:
      true if String with data
    • exists

      public static boolean exists(javax.servlet.http.HttpServletRequest request, String parameter)
      Does Parameter exist
      Parameters:
      request - request
      parameter - string
      Returns:
      true if String with data
    • isEmailValid

      public static boolean isEmailValid(String email)
      Is EMail address valid
      Parameters:
      email - mail address
      Returns:
      true if valid
    • propertiesEncode

      public static String propertiesEncode(Properties pp)
      Decode Properties into String (URL encoded)
      Parameters:
      pp - properties
      Returns:
      Encoded String
    • propertiesDecode

      public static Properties propertiesDecode(String data)
      Decode data String (URL encoded) into Properties
      Parameters:
      data - data
      Returns:
      Properties
    • convertToOption

      public static org.apache.ecs.xhtml.option[] convertToOption(NamePair[] list, String default_ID)
      Convert Array of NamePair to HTTP Option Array.

      If the ArrayList does not contain NamePairs, the String value is used

      Parameters:
      list - ArrayList containing NamePair values
      default_ID - Sets the default if the key/ID value is found. If the value is null or empty, the first value is selected
      Returns:
      Option Array
      See Also:
    • createField

      @Deprecated public static org.apache.ecs.xhtml.tr createField(org.apache.ecs.xhtml.tr line, String FORMNAME, String PARAMETER, String labelText, String inputType, Object value, int sizeDisplay, int size, boolean longField, boolean mandatory, String onChange, StringBuffer script)
      Deprecated.
      Create label/field table row
      Parameters:
      line - - null for new line (table row)
      FORMNAME - form name
      PARAMETER - parameter name
      labelText - label
      inputType - HTML input type
      value - data value
      sizeDisplay - display size
      size - data size
      longField - field spanning two columns
      mandatory - mark as mandatory
      onChange - onChange call
      script - script
      Returns:
      tr table row
    • createClosePopupButton

      @Deprecated public static org.apache.ecs.xhtml.input createClosePopupButton(Properties ctx)
      Deprecated.
      Get Close PopUp Buton
      Returns:
      button
    • streamAttachment

      public static String streamAttachment(javax.servlet.http.HttpServletResponse response, MAttachment attachment, int attachmentIndex)
      Stream Attachment Entry
      Parameters:
      response - response
      attachment - attachment
      attachmentIndex - logical index
      Returns:
      error message or null
    • streamFile

      public static String streamFile(javax.servlet.http.HttpServletResponse response, File file)
      Stream File
      Parameters:
      response - response
      file - file to stream
      Returns:
      error message or null
    • deleteCookieWebUser

      @Deprecated public static void deleteCookieWebUser(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String COOKIE_NAME)
      Deprecated.
      Remove Cookie with web user by setting user to _
      Parameters:
      request - request (for context path)
      response - response to add cookie
    • getFrom

      public static String getFrom(javax.servlet.http.HttpServletRequest request)
      Get Remote From info
      Parameters:
      request - request
      Returns:
      remore info
    • addCookieWebUser

      @Deprecated public static void addCookieWebUser(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String webUser, String COOKIE_NAME)
      Deprecated.
      Add Cookie with web user
      Parameters:
      request - request (for context path)
      response - response to add cookie
      webUser - email address
    • updateFields

      @Deprecated public static boolean updateFields(javax.servlet.http.HttpServletRequest request, WebUser wu, boolean updateEMailPwd)
      Deprecated.
      Update Web User
      Parameters:
      request - request
      wu - user
      updateEMailPwd - if true, change email/password
      Returns:
      true if saved
    • getServerName

      public static String getServerName()
      Get server name
      Returns:
      Server name including host name: IP : instance name
    • getHostIP

      public static String getHostIP()
      Get server ip
      Returns:
      server ip
    • isUrlOk

      public static boolean isUrlOk(String urlString)
      returns true if the URL exists and answer with a 200 code
      Parameters:
      urlString -
      Returns:
      boolean