S
S
Sadrutdin Zainukov2017-08-20 20:09:13
Java
Sadrutdin Zainukov, 2017-08-20 20:09:13

Where to write methods from main(String args[]) jar in web application?

I need to implement editing properties and displaying logs on a web page.

jar application components:

  • a simple Http server (for receiving messages and sending requests);
  • Telegram bot;
  • JDBC;
  • reading properties file.

Everything is working. With servlets, jsp, etc. I’ll figure it out, but I just can’t figure out where to write what I wrote in main(String args[]) , and how will it be possible to restart all this after editing properties through a web page?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Odissey Nemo, 2017-08-24
@odissey_nemo

It is not very clear what is meant by

then where to write what I wrote in main(String args[])
. But if we assume that we are looking for a method where everything is initialized and the user code is run for the first time, then this could well be a class in an HTTP server (written in Java) that extends the HTTPServlet system class and overrides its init method. Like the one below:
public final class CustomerDispatcher extends HttpServlet {
...
   // Вызывается при инициализации сервлета!
   public void init(ServletConfig config) throws ServletException {
      super.init(config);
      this.context = config.getServletContext();
      this.contextPath = this.context.getContextPath();
      this.rp = new RequestProcessor(this.context);
      this.sman = FssServiceFactory.getFactory().getSecurityManager();
   }
...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question