Neo Wills

Ranch Hand
+ Follow
since Nov 29, 2006
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
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Neo Wills

Hi,

I tried building the 6.0.x tomcat source. From the installation looks like we had to execute "ant download" and then "ant".

Executing "ant download" completed fine. But executing "ant" after it fails with this error:

Any idea if some envt variable is messed up ? The JAVA_HOME path is pointing right at the jdk directory - /usr/lib/jvm/java-6-openjdk/.



Neo.
14 years ago
Thanks Folks.

Did not know that we cant send a response without getting a request. That means we really cant do much on long running processes.

If webservers interact with application servers, does the response always happen in the same thread where it gets the request?

Like if the webserver wanted to get some info from the application server, it does it then and there and replies inline?
14 years ago
Thanks William.

The external process creates a socket on a port and keeps waiting on it. All the webserver has to do is to bind to it.

1. When you say we can store the reference in servlet context, you mean through setattribute? I can look more into that.
2. Since blocking on the request/response thread is not good, can I reply for a session from a different thread?
3. I can get the session id from the http request. But how do I convert it back to http request and use to send response back?

Neo
14 years ago
Hi Mark,
There is no doubt in how the IPC / Thread communication needs to work here. There are only 3 clarifications I need from the servlet environment:

The external client (X) is not going to give me the info of which web client I need to respond to. This needs to be stored in some global data structure in the webserver and when the response comes from the external client I need to figure which webclient to respond to.
1. How do I store the global data structure in servlets (across all sessions) with each web client's connection info?
2. Does my servlet thread have to be blocked in condvar till the response comes from the external client? Or can I respond from a different thread?
3. If I can respond, what is the web client's connection info we need to hold? In case of normal ipc, its just fd's. Would storing "HttpServletResponse response" be good enough for responding later for that client?

Neo
14 years ago
For example, I create a thread in the init() routine in the servlet, which binds to some port opened by the external client.

Thread Sender in webserver:


Thread Receiver in webserver:

Thread which gets the request from the client in webserver:
14 years ago
In a standard application, C1 sends some info to the webserver. I can have the connection info of C1 stored in some data structure and send the non blocking request to X.

When the response for X comes back on a different thread, I can look up the connection info of C1 from the data structure and reply on that.
14 years ago
Ok. This is how it would have been done on a standard client app

Events are shown in timeline here:
T1 C1 ------> Web Server
T2 Web Server ---(nb socket send Request1)------> X
T3 C2 ------> Web Server
T4 Web Server ---(nb socket send Request 2)-----> X
T5 Web Server <---(nb socket resp Response 1)----X
T6 Web Server <---(nb socket resp Response 2)----X

The webserver would receive responses on a dedicated thread from X. Now how would it respond to C1 and C2?
14 years ago
Hi Mark,

Thanks for the input. But the response to the servlet should be back in less than a second. Still I dont want this thread to be blocked for that 1 second just for the response from the external process.

Say I get client requests A1, A2 and then the servlet sends the non blocking msg for these to X. When the response comes for A1 on the dedicated thread, how can the servlet respond for A1 to the client?

Neo
14 years ago
Should the response for the external client be done only from the same thread on which it got invoked?

Say this is the code piece:



Later when X sends back the response on a socket to the webserver in a separate dedicated thread, can we respond to the external client request?
14 years ago
Pardon me for not being clear.

Each time a new request from a client is obtained, the webserver needs to send out a non blocking msg on the socket out to a process X. Later it receives a msg over socket from X and has to correlate it to which client request it got that reply for and respond to the client.
14 years ago
Hi,
If the webserver want to communicate through non-blocking with some process for each http request it gets, the webserver will need to store some information to handle the reply part of it. But the current mechanisms I see dont really provide a nice method to store and retrieve that info. Is there any known methods for that?

Neo
14 years ago
For ex, I have an integer 10, for converting to fixed length string of 8 bytes it would be "00000010".
14 years ago
Hi,
I was trying to convert an integer into a fixed length string (say 8 bytes). Which would be the most optimal way to do this?

Bharath
14 years ago
Also cant I just have define it in the init() method of the servlet to make it global for the whole lifetime tomcat stays up?
14 years ago
Thanks for the info. Shall look at connection pools. But is there any code sample for using the application context? Googling returns it mostly as the context info the deployment desc file...
14 years ago