Package org.apache.wiki.ajax

# Class AjaxUtil

java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
org.apache.wiki.ajax.AjaxUtil

All Implemented Interfaces:
  `jakarta.servlet.Servlet`, `jakarta.servlet.ServletConfig`, `Serializable`

public class AjaxUtil extends jakarta.servlet.http.HttpServlet
Helpful utilities for the Ajax functions.

Since:
  2.10.2-svn12
See Also:
  - Serialized Form

## Field Summary

### Fields inherited from class jakarta.servlet.http.HttpServlet

`LEGACY_DO_HEAD`

## Constructor Summary

Constructors
Constructor
Description
`AjaxUtil()`

## Method Summary

Modifier and Type
Method
Description
`static String`
`getNextPathPart(String path, String lastPart)`
Given a requestUri path, find the next uri "fragment" after the "/lastPart/" one.
`static String`
`toJson(Object input)`
Uses Google Gson (https://code.google.com/p/google-gson/) to convert to JSON

### Methods inherited from class jakarta.servlet.http.HttpServlet

`doDelete, doGet, doHead, doOptions, doPatch, doPost, doPut, doTrace, getLastModified, init, isSensitiveHeader, service, service`

### Methods inherited from class jakarta.servlet.GenericServlet

`destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### AjaxUtil

public AjaxUtil()

## Method Details

### toJson

public static String toJson(Object input)
Uses Google Gson (https://code.google.com/p/google-gson/) to convert to JSON

Parameters:
  `input` - the object to be converted to JSON
Returns:
  the JSON string of the object

### getNextPathPart

public static String getNextPathPart(String path, String lastPart) throws jakarta.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)

Parameters:
  `path` - the RequestURI to search usually done by calling request.getRequestUri().
  `lastPart` - the previousPart of the path to search after.
Returns:
  the next part of the path.
Throws:
  `jakarta.servlet.ServletException` - if `path` does not contain `lastPart`