Class AjaxUtil

  • All Implemented Interfaces:, javax.servlet.Servlet, javax.servlet.ServletConfig

    public class AjaxUtil
    extends javax.servlet.http.HttpServlet
    Helpful utilities for the Ajax functions.
    See Also:
    Serialized Form
    • Constructor Summary

      Constructor Description
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String getNextPathPart​(java.lang.String path, java.lang.String lastPart)
      Given a requestUri path, find the next uri "fragment" after the "/lastPart/" one.
      static java.lang.String toJson​(java.lang.Object input)
      Uses Google Gson ( to convert to JSON
      • Methods inherited from class javax.servlet.http.HttpServlet

        doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, service
      • Methods inherited from class javax.servlet.GenericServlet

        destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • toJson

        public static java.lang.String toJson​(java.lang.Object input)
        Uses Google Gson ( to convert to JSON
        input - the object to be converted to JSON
        the JSON string of the object
      • getNextPathPart

        public static java.lang.String getNextPathPart​(java.lang.String path,
                                                       java.lang.String lastPart)
                                                throws javax.servlet.ServletException
        Given a requestUri path, find the next uri "fragment" after the "/lastPart/" one. E.g. given url "/test/abc/travel", and lastPart "abc", this will return "travel". Given lastPart "test" will return "abc". This could be done better using a URITemplate (as RFC6570)
        path - the RequestURI to search usually done by calling request.getRequestUri().
        lastPart - the previousPart of the path to search after.
        the next part of the path.
        javax.servlet.ServletException - if path does not contain lastPart