Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

different act depending on the source of a CGI string?

Status
Not open for further replies.

igowi

Programmer
Sep 18, 2001
45
US
When a cgi string is sent from a web browser, the web server could notice which web browser send this string??

If it's sent by a Java program, the server knows this is not sent by a web browser???

The server could act differently depending on who sent this cgi string???

A web server could respond differently depending on the source of a CGI string???
 
ummmmm, huh? If you are asking if a server can determine how to serve a page based on whether the remote client is java enabled, I don't think so. You can however get a cgi or java script that will check for it and redirect to a particular url based on the results.
 
You mean that a web server doesn't know who is a client of the server?

then
How can a CGI script get the information of the clients?

CGI script could have what information of clients?

thanks.
:)
 
Yes the apache server does know some information about the client. If you look in your access logs and error logs, you will see that information posted. It can also post more information. Look in the section of httpd.conf where logs are defined and you will see what I mean. Apache doesn't use this information. It only gathers it if requested and writes it to a file. It doesn't care what type of browser you are using. It determines how to handle pages by their extention or content. For example, if an html page is requested, That page is served to the client (browser). If it is a cgi script it gets handled by perl for execution then the result is sent to the client in html format. Java is different. In most cases, it is not executed on the server. It is parsed then sent to the client which in turn does all the work. If your browser isn't java enabled, it will crash or just won't display the output. Apache doesn't know and doesn't care about the browser. It's job is to serve pages and execute scripts. If you need a page to act on whether or not the browser is java enabled, you will have to download or create a script for that. I hope I'm helping. It's hard for me to understand what you are asking.
 
Thanks a lot.
It helps me.

Apache doesn't care about the browser.
But, the perl script might care about the browser and it can deal differently depending on browser?

It's hard for me to explain what I don't know in English.
:)


 
That is correct. The same is true for java and html. browsers handle things differently.
 
When I click a Logout button from the web browser, it directs me to the first page for authentication. (I can see login page.) so, I checked the html source. Just there is a button which directs to /logout.html. the logout.html is same as login.html. When I see the html page, the web browser doesn't send any string and request the logout.html.
Why can't I go back to the page which I can see after authentication? The web server is doing something else for the request the logout.html? What's happening between the web server and web browser for this case?

 
Is this Authentication a pop up window or a form on the html page. If it is a pop up window, the server is using .htaccess. You will only see this the first time you enter that directory where the page is. As long as you are in that directory, you will still be authorized and not see the window again. There are also scripts that can perform this function and none of them will show when you view the source. These scripts can also perform redirects based on URL destination, web browser, system type and many more. Have you ever clicked on a banner or button and even though it shows a url in the url box, it sends you to another place or opens a bunch of other windows? None of these have to do with the server not knowing what to do when yo press a button. I hope I understood your question.
 
Hi,

Regarding the original query - Even outside of cgi, you can use the apache environment variables in conjunction with mod_rewrite or mod_access to cause apache to behave differently (e.g. for different browsers or java) depending on what you want to happen.

For example, to send IE users away ....

RewriteEngine on

RewriteCond %{HTTP_USER_AGENT} ^Mozilla.*
RewriteCond %{HTTP_USER_AGENT} !^.*MSIE.*
RewriteRule ^/$ /mozilla.html [R,L]

RewriteCond %{HTTP_USER_AGENT} ^.*MSIE.*
RewriteRule ^/$ [L]

RewriteRule ^/$ /index.html [R,L]


For mod_rewrite see --> .

You can also create some more complex logic by setting your own environment variables with setenvif . See -->
Regards
 
THANK YOU.
1. Is there any case a web server is serving to one client at a time and can reject another client while it's serving to the other client?
How does it do?
also in the CGI script?

2. I access to example) by a web browser.
and then I get a html page from the server.
on the page, I click one button(it directs me to
Internally the web brower opens just one socket to the server?
or it opens two sockets for the requests.

hope it makes sense to you this time.
 
I don't want to sound rude but why are you asking these questions? Sometimes when you know why a person is asking something, it help understand the question better. Sorry if I'm offending you and I want to help but do not understand. Do you have you own server and want to make it do something. Are you writing a script and want to know how to get information from the browser or server? Did you see something on a website and want to duplicate it? That is what I am trying to understand.
 
Hi,



At the basic html level, there are no long lasting 'sessions' between client and webserver. A client (browser) sends GET requests for pages and GIFS, etc., and, for each one, the server sends the output which the client reassembles and renders the page. Once the server has served the output it breaks the TCP session at its end. If you request a page from a server then as soon as the server sends the output the TCP session is ended . If you then click on a link on that page its another (totally separate) session.



Servers like slashdot.org are getting thousands of hits at the same time and each one would be evaluated in the same way. Using the example I gave earlier its like (i) receive request (ii) check calling browser (iii) if mozilla return a page in mozilla directory (iv) if IE send away (v) else serve default index. This logic is repeated for all requests so the server doesn't go into a 'mode' while its serving one client - its multi-threaded and will have lots of handlers spawned anyway (depending how busy it is).


Apache can also apply lots of logic based on IP address of caller, user authentication, etc., etc. All of this can be done without cgi.



Hope this helps











 
Thanks.

I am making java program to imitate a web browser.
I want to do same things by my program as by a web browser.
By the java program, I am reading html file and sending form data.
But, most of the time, it’s working properly. But, sometimes, it’s not working. (I don’t know what circumstances it’s not working under.) When It was not working, I tried to send same cgi string several times by my program , then it’s working again.
That’s why I am thinking of the lower level for the communication between client and server.
Through web browser, it didn’t happen same thing as the weird thing by my program. So, I thought that their communication could be different. But, by your answer, they seem to work similarly. (The web browser communication open one socket and my java program opens several sockets? I doubt it could be problem. )

Then now I am thinking that the testing is wrong. To test if my program is working properly, I run my program and I am checking through web browser. It could be problem?

What do you think?

(You are not offending me at all. Thanks for your help.)
 
Thanks.

Recent versions HTTP supports Keep-Alive.
I assume recent web browsers also support Keep-Alive.
If the Java doesn't support Keep-Alive, what do you think problems would be.
This could cause any different responses from a web server.
One support this.
The other doesn't support that.
The only difference is just performance?


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top