how internally doPost method in servlet works [closed] - java

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Why query string is not getting created in doPost method of HttpServlet?
Is this reason is enough - it is supplying data in html body.
can anyone please clarify what actually happening

Get and post methods are almost the same, the only difference between these two methods is that: in post, query strings (name/value pairs) is sent in the HTTP message body of a POST request and in get, query strings (name/value pairs) is sent in the URL.
Why is this done this way, obviously, security reasons.
You do not want to see your login credentials in the url.

Related

Postman Testing [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I am trying to test in Postman a rest end point url. I am unable to upload a file and 2 JSON Objects, both at a time from Postman.
I can do it separately, I mean I can choose a file from form-data(Postman). Can send a JSON object from raw(Postman).But I cannot do at a time both.
Can some one please help me on this.
Using Body->form-data you can put your file and a JSON file(.json extension) with your JSON content.

Send list of objects as response in Java [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Is it possible to send a list of objects as a response to a HttpGet request in Java? I can't find anything about how to accomplish this.
Yes, it possible to send the list of objects as a response to GET/POST response.
It would entirely depend on how you are exchanging data between client and server. For example, you are exchanging data in JSON then you have to use libraries like Jackson which can convert your Java object to JSON, if you are using XML then same told true for it.
Read here for available options with JSON, also feel free to read this answer, however it talks more about traversing JSON.
Updates based on OP's comment
Approach always remains same, you will send response to client in some format, you will use HttpServletResponse method like set content type etc. where you will set the content type (XML or JSON etc.) and write to the response stream and then flush the stream.
Please have a look at this question.

Efiiciency for Pagination in Java [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am writing Pagination for a set of records in Java. Here i am talking to a service which fetches a result set of 500 per time. I interact with that service to display at most 50 records at a time with page markers.
Is it a really efficient model or if there is any other way to improve the suggested pagination model ?
Depends on your data.
If your data is rapidly changing, this definitely isn't a suitable method. I would suggest tweaking the service to return only as much requested records that are needed by the page.
If data is static and need not be time dependent, this should work fine. Just fetch the 500 records, put it in a local array and display from there. Once this is exhausted, replenish the same.

How to catch html response in Java? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I'm going to get Html responses and do some modifications on responses in Java before they reach client.
My idea is writing a servlet-filter but I don't know how to implement that.
What I got is :javax.servlet.ServletResponse resp and javax.servlet.ServletRequest req.
The essentials of filters
check the part on modifying responses
In your servlet filter, you can provide your own subclass of HttpServletResponseWrapper
After the call of chain.doFilter(...), your response wrapper will contain the html content, you'll be able to retrieve and transform it.
You can find a similar servlet filter there as example : http://www.onjava.com/pub/a/onjava/2003/11/19/filters.html
use head first's chapter for filter there is an example of HttpServletResponseWrapper. very nice book for servlet and jsp s.

How to avoid resending emails or missing emails in this case? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
dataContext.saveSend(true);
SendEmailsToAllMembers();
I have the code above, if after half of the emails were sent out, there is a error in smtp, then how can I avoid resending emails or missing emails in this cases ?
Inside the SendEmailsToAllMembers you could store which emails have been successfully sent to. Repeat calls to the method could check if this email has already been sent successfully and therefore not resend it.

Categories