readvalue.java:
Код: Выделить всё
@WebServlet("/readValue")
public class ReadValue extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
response.getWriter().println("Value is " + value);
}
}
Код: Выделить всё
@WebServlet("/incrementValue")
public class Increment extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
value++;
response.getWriter().println("Now value is " + value);
}
}
Код: Выделить всё
@WebServlet("/decrementValue")
public class Decrement extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
if (value > 0) {
value--;
response.getWriter().println("Now value is " + value);
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/798 ... e-servlets
Мобильная версия