views:

106

answers:

3

hi, I have been in web programming for 2 years (Self taught - a biology researcher by profession). I designed a small wiki with needed functionalities and a scientific RTE - ofcourse lot is expected. I used mootools framework and AJAX extensively.

I was always curious when ever I saw the query strings passed from URL. Long encrypted query string directly getting passed to the server. Especially Google's design is such. I think this is the start of providing a Web Service to a client - I guess.

Now, my question is : is this a special, highly professional, efficient / advanced web design technique to communicate queries via the URL ?

I always felt that direct URL based communication is faster. I tried my bit and could send a query through the URL directly. here is the link: http://sgwiki.sdsc.edu/getSGMPage.php?8 By this , the client can directly link to the desired page instead of searching and / or can automate. There are many possibilities.

The next request: Can I be pointed to such technique of web programming? oops: I am sorry, If I have not been able to convey my request clearly.

Prasad.

+1  A: 

I think that essentially what you are asking about is query strings. In a url after a page, there may be a question mark after which, there may be URL parameters (generally called GET request parameters.)

http://www.google.com/search?q=URL+parameter

Generally, processing this would be done on the server-side. For example, in PHP, one could use the following:

$_GET['q']

The aforementioned code would be the value of the variable. Alternatively, to do this client-side, one could use anchors. Replace the question mark with a hash sign #

Since this is used for anchors, when a URL is changed to have an anchor tag, the page is not refreshed. This allows for a completely AJAX-driven page to manipulate the URL without refreshing. This method is often used also for enabling back-button support for AJAX pages.

In JavaScript, one can use the onload handler as an opportunity to read the URL of the page and get the hash part of the URL. The page could then make a request back to the server to read any neccessary data.

Maz
thanks maz for the reply. I learnt to some extent, the GET and POST variables and used them extensively in my work. However, thanks for the # part of your explanation. I didnt know that. Wow!! I had this problem of back button support for Ajax Pages. I should try this out for my wiki. thanks for the tip.
Prasad
Be warned though, I don't think that fixes the back button issue in IE. For a solid implementation of both back button and # variables, you should try the dojo.back module in Dojo (http://dojotoolkit.org/)
Maz
+1  A: 

I think this is the start of providing a Web Service to a client - I guess.

No not really, although it can be. Its used to have a central entry point to the entire application. Its a common practice and has all kinds of benefits, but its obviously not required. Often thes days though even a normal url you see may not actual be a physical page in the application.. each part of the path may actuall be mapped to a variable through rewriting and routing on the server side. For example the URL of this question:

http://stackoverflow.com/questions/2557535/general-web-programming-designing-question

Might map to something like

http://stackoverflow.com/index.php?module=questions&action=view&question=2557535&title=general-web-programming-designing-question

is this a special, highly professional, efficient / advanced web design technique to communicate queries via the URL ?

Having a centralized page through which all functions within an application are accessed is part of the Front Controller Pattern - a common pattern in applications generally used as part of the overall Model, View, Controller (MVC) pattern. In MVC, the concerns of the application are divided into the model which holds the business logic. These models are then used by the controller to perform a set of tasks which can produce output. This output is then rendered to the client (browser, window manager, etc..) via the view layer.

prodigitalson
yeah!! I was expecting this answer. I was not aware of MVC in the first place. But, from your excellent summary of MVC, I am clear where the time is spent to make a good application. MVC looks pretty logical and deep rooted. Thank you once again. The mapping example which you have mentioned also is exactly what I was trying hard to ask in my question. Does it also mean, from the way the communication goes, there seems to be no ajax usage in this type of design ?Am I right in saying that the Controller in MVC is a conduit which communicates with Business Logic and Client?
Prasad
No these dont preclude ajax at all. Ajax is jsut a way to transmit data to the server and recieve a response without updating the entire page, instead only updating the specific data/area on the page that is relevant. As far as you definition of MVC i suppose you could put it that way, but those are not the terms i would use. I suggest you simply Google for MVC and Front Controller. Ther will be a wealth of information, explanations and examples :-)
prodigitalson
A: 

It's a consequence of using a front controller architecture. This fits neatly with the idea of a wiki where the same code is used to render multiple different wiki pages - the content is defined by the data.

Using the query part of the URL for the page selection criteria is not the only solution. e.g. if you are using apache then you could implement:

http://sgwiki.sdsc.edu/getSGMPage.php?8

as

http://sgwiki.sdsc.edu/getSGMPage.php/8

(you'll need to add your own parsing to get the value out.

Alternatively, you can use mod_rewrite to map components out of the path back into the query.

There's no particular functional/performance reason for adopting any of these strategies. Although it is recommended, where the URL is idempotent, that each page be addressable via a GET operation (also useful for SEO).

C.

symcbean