Monday 15 March 2010

java - Processing heavy operations with doGet() method on a servlet -


The tool I'm working on can send a GET request only, and I am using that information The process requires the request. This operation returns a string that contains the URL that I will use for redirection.

After doing some research, I have found that doGet () method is used for pre-processing, while doPost () can be used for post processing.

Is there any way I can take these heavy actions using the doGet () method? If I want to use the doPost () method, how can I "turn on" my request in the POST request?

Thank you.

EDIT: I have already tried to process these heavy actions within the doGet method. But it seems that unless the URL string is used for redirection, the servlet does not wait. I have read that trying to synchronize based on the performance of your doGet () method is a bad thing.

Edit 2 - What I'm trying to do: The tool I'm working on is an Oracle. You can launch custom actions within the client including web applications. A GET request will be sent to the application by launching a custom action, which will contain all the information about the page from which you launched the application (users, items selected, etc.) and then use this information to take huge action Does what I told about it In operation, using a single ID on the Oracle client, creating a query based on the selected item, creating XML data and using external programs located on the Oracle server, a new session is created. Finally, it gives a download URL from which you can download a PDF report, and I am using this URL to redirect the application.

Here is the servlet code:

  Package .servlets; Import java.io.IOException; Import javax.naming.InitialContext; Import javax.servlet.ServletConfig; Import javax.servlet.ServletException; Import javax.servlet.http.httpServlet; Import javax.servlet.http.HttpServletRequest; Import javax.servlet.http.HttpServletResponse; Import com.actions.agileSessionHandler; Import com.actions.BOMComparisonReport; Public class DefaultServlet HttpServlet {Public Zero doGet (HttpServletRequest request, HttpServletResponse response) enhances ServletException, IOException {agileSessionHandler handler = new agile session handler (...); BOMComparisonReport Report = New BOMComparisonReport (...); Handler.setSessionObject (request); String url = report. GenerateBOMReport (...); Request.setAttribute ("redirectURL", url); This.getServletContext () GetRequestDispatcher ("/WEB-INF/BOMCompDefault.jsp") Forward (request, response); }}    

I already take action on these heavy Attempted to do the operation within the DoGet method but it appears that unless the URL string is used for redirection, the servlet does not wait

it seems Just like you're firing a new thread and forgetting it completely. This is a very bad idea in the Java e environment. Do not do this, just do processing in a very thread (i.e., no one makes new threads) ). If you really intend to do it in asynchronous form, then you should use the example method for voting to inform the customer about progress / results on @ asynchronous on EJB and then Use or push.

It does not matter whether you get it GET or Post Request issue, request idempotent, bookmarkable, exactly executable with exactly the same result every single SQL SELECT Think about the query, there are no post requests. Think of executing SQL UPDATE or DELETE queries that are being used to manipulate data at the end of the server. You do not want your data to be modified or deleted on every F5 press or when a searchboat comes with indexing of GET links, right?

No comments:

Post a Comment