If you want to access Liferay service API, you may consider using PortalDelegateServlet : adding the following to your web.xml:
<servlet>
<servlet-name>myServlet</servlet-name>
<servlet-class>com.liferay.portal.kernel.servlet.PortalDelegateServlet</servlet-class>
<init-param>
<param-name>servlet-class</param-name>
<param-value>org.example.MyServlet</param-value>
</init-param>
<init-param>
<param-name>sub-context</param-name>
<param-value>myservlet</param-value>
</init-param>
</servlet>
will make your servelt accessible through
http://example.org/delegate/myservlet
in your servlet class, you then do things like extract the logged-in user and check permissions:
package org.example;
public class MyServlet extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
User user = PortalUtil.getUser(request);
PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(user);
...
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…