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.
Related
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.
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.
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.
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
I would like to be able to send a JSON string to a server, then let the server process the string and give me a proper response all using Java.
Here's an example:
{
"requestType": "SomeType"
"name": "Steve"
"age": 37
}
Then the server would then give a proper response.
{
"reponseType": "Ok"
}
Should this be done through an HTTP request or something else and if so, how would I go about this?
Yes, this would be done through an HTTP request. Based on your question containing a Java tag, I would suggest you look into Java Servlets/JSPs and research a server that implements the Servlet/JSP specs (e.g., Apache Tomcat). The following site is a good reference for learning about these topics: Core Servlets
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 5 years ago.
Improve this question
<tickettypes>
<eventid>8</eventid>
<eventname>air</eventname>
<tablename>tbl_tickets</tablename>
<ticketid>1</ticketid>
<name>Platinum</name>
<price>200.00</price>
<printable>Y</printable>
<ticketid>2</ticketid>
<name>Gold</name>
<price>150.00</price>
<printable>Y</printable>
<ticketid>3</ticketid>
<name>Silver</name>
<price>100.00</price>
<printable>Y</printable>
<ticketid>4</ticketid>
<name>Test</name>
<price>50.00</price>
<printable>Y</printable>
<surveys>
<surveyid>0</surveyid>
<surveyname>No Survey entered</surveyname>
<surveyid>1</surveyid>
<surveyname>Advertisement</surveyname>
<surveyid>2</surveyid>
<surveyname>Friends</surveyname>
<surveyid>3</surveyid>
<surveyname>Web Reference</surveyname>
<surveyid>4</surveyid>
<surveyname>News Paper</surveyname>
<surveyid>5</surveyid>
<surveyname>portals</surveyname>
</surveys>
</tickettypes>
can any one please help me how to parse the following xml file
The best way to read XML in Android is to use the Simple XML Framework. If you want a step by step guide then you should take a look at the blog post on the topic that I wrote. If you knew simple then this would take you all of ten minutes to write the code that can parse it.
There are quite a few examples of this online; the first page of a Google search "parse xml in java" was filled with examples.
http://www.java-samples.com/showtutorial.php?tutorialid=152
http://www.totheriver.com/learn/xml/xmltutorial.html
http://www.developerfusion.com/code/2064/a-simple-way-to-read-an-xml-file-in-java/