mi go

Greenhorn
+ Follow
since Apr 21, 2017
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
7
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by mi go

I have one servlet having void service method that publishes MQTT msg to broker and servlet contains msgArrived function as follows:(using MTQTT paho library)


now i want to get this received msg and transfer it to another servlet as response which is making this servlet a request. But service method of this servlet ends before it receives a msg from broker hence it is transferring null response . How can we acheive this. can we use synchronize method somehow so that service method of this servlet waits for the response from broker and then send response to another servlet.
6 years ago
Thanks and how ca we use response object outside of service() methof of servlet?
6 years ago
Can we convert normal string to HttpServletResponse or HttpServletRequest object?
6 years ago
I have Two servlets Account and Billing. Account sending string in GET req to Billing and Billing capitalizing the String and sending back via REsponse. Now I want to insert proxy in between whihc is called Billing only so communication is like
Account--->Billing(Proxy)--->Billing  and response should be Billing--->Billing(proxy)...>Account.  Following is code for all servlets

Account.java



Billing.java THIS IS PROXY


Actual BILLING.java

I am receiving output as follows:
200 response from target proxy to Account
Account servlet sending data :abc

capitalizedStringFromBilling in account as response
THIS IS HELLO FROM PROXY FOR WebApp2
200 response from Billing to proxy
ABC
ABC

that means i am not able to forward responce from actual Billing to Account via proxy as nothing is printed after "capitalizedStringFromBilling in account as response"

whats wrong?



6 years ago
Yes its making call to different servlet namely WebApp1/Account who has got doPost() method. My question is that whether its normal to do or not? Or to have another servlet in WebApp1/AccountHandle that will have doGget().
6 years ago



is it okay to have POST type method in doGet() ?
6 years ago
I want to ask  general question regarding deployment descriptor (web.xml) file?
Can we specify communication endpoint in this file ?
for example I m using HTTPUrlConnection class in Servlet1. This Servlet1 then send GET reqest to Servlet2 which is running in VM and which processes the requst and prints something. By communication endpoint i mean the URL of Servlet2 which i have to specify in Servlet1 code. I want to access this URL somehow from web.xml of Servlet1. So in cases when Servlet2 moves to some other URL, i dont have to modify the Servlet1 code but web.xml of Servlet1.

Also can we specify somehow which HTTP methods are being used in which servlet by web.xml?
6 years ago
How to receive the parameters that are sent by the POST method in a servlet.
i am sending parameters in POST as follows:



Now how will i receive the str1 in Accountservlet. I am receiving null.
6 years ago
I have one web application project in servlet called WebApp1 consiting of one servlet Account.java and one input.jsp file. Currently i have web.xml defined for WebApp1 as follows:



input.jsp is as follows:


so i have WebApp1 folder in my webapps directory of tomcat therefore the url i need to follows is http://localhost:8080/WebApp1/input.jsp

but i wish to use http://localhost:8080/input.jsp this url. How to make use of ROOT directory of tomcat for that?
6 years ago
How to use HTTPUrlConnetion class to communicate bewtween two servlets like passing the data from one servlet through GET or POST method and have it returned from second servlet. Both servlets are in different web projects! Can someone post the code ?

i have created following code:

WebApp1 have input.jsp as follwos:

and Account servlet

WebApp2 have billing servlet that basically capitalises string and print it:

When i run http://localhost:8080/WebApp1/input.jsp  and send a string(e.g. fdfd) via test box and enters submit button
this url is hit http://localhost:8080/WebApp1/Account?t1=fdfd but it did not capitalise the string and fileNotFoundException comes.

can someone help me? whats wrong
6 years ago
Communication is just like that i.e passing of parameters or two servlets saying Hi to each other simply(chatting app)


It is not picking up anything from browser.

servlet 1 code:



servlet2 code:


6 years ago
to get straight i am looking for mechanism that allows two servlet to communicate with each other residing on differernt hosts i.e. one on host OS(host 1) and one on VM(host 2). I am corncerned about environment setup(tomcat) and the code for the servlet.  
6 years ago
Actually i am not understanding the server part in servlet technology. Consider following scenario that i currently have.

I have windows system on which i have installed apache tomcat and consists of two servlets namely Servlet1 and Sevlet2. Servlet1 passes one parameter to servlet 2 so when i go to url of servlet2 on localhost, it shows that parameter. Now i have to seperate servlet1 and servlet2 say servlet1 reamains on host OS and servlet2 on windowsVM and then have same type of communication between them. What things i have to do with windowsVM like install eclipse,tomcat etc?  Do we need two tomcat servers on both the hosts i.e one on VM and one on Host OS ?
6 years ago
So if i setup a VM on my laptop running windows then will it be treated as different host ?
if yes then i want to have communication between two apps/servlets, one in VM and one in my laptop....also it is confusing the difference between apache tomcat and apache http server.....can you explain what exactly HTTP client needs?
6 years ago
so we have to write client+server code a both the places.  Can this be realised in using servlet and tomcat server ? Can you provide some examples or source code for it?
6 years ago