• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

alternative to query string

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All,

Please let me know if there is any alternative to query string for passing data. The problem is that its a link (href) through which query string is passed and hence we cannot use request or session objects. Please suggest on this..

Regards
Atiq
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could use a form with method=post, and your link could be a javascript call that submits the form.


[ August 27, 2008: Message edited by: Steve Luke ]
 
Mohammad Atiq Kazi
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply..

But my problem is that the link will be visible in mobile handset and when the user clicks on it, it will connect to application and based on the query string it will retrieve information and send it back to the user. I need to find a way to remove the query string and shorten the url.
 
author & internet detective
Posts: 42011
911
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mohammad,
If you use a POST, just the action name is shown in the URL. The parameters are not shown.
 
Sheriff
Posts: 28329
96
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is your problem that the URL is too long, or is it that there is a visible query string?
 
Mohammad Atiq Kazi
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the replies...

My requirement is to shorten the url. Its a link which will be visible in mobile handset with some query string in it (to say in midlet application). The midlet will communicate to application to fetch data. I am searching for an alternative to query string for shortening url.

Regards
Atik
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I has been a while since I looked at midlet capabilities.

Are you saying the a midlet can ONLY generate a GET? I thought POST was also possible.

Bill
 
Steve Luke
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Another alternative would be to use 'friendly' urls, like:
http://myserver.com/context/Steven/1/displayage.jsp
rather than
http://myserver.com/context/diaplayage.jsp?name=Steven&age=1

It makes the URLs easier to read and gets rid of the query string, but makes it a bit more complicated to put them in/pull them out of the URL. They must be ordered (if you couldn't do /context/1/Steven/displayage.jsp if the page expected /context/Steven/1/displayage.jsp) and you would need to implement a control structure that can correctly parse the URL, pull out the parameters then forward to the proper display. Not a big issue if you are using a FrontController.

For small number of parameter name/value pairs the difference is minimal (as you can see above, but for large number of name/value pairs the difference is large.

(I have also seen 'friendly' urls written as: http://myserver.com/context/displaypage.jsp/<param value 1>/<param value 2> instead of http://myserver.com/context/<param value 1>/<param value 2>/displaypage.jsp I guess because it makes it easier to parse out the directory structure of where the displaypage.jsp page is... not sure which is preferred or normal, but I like the having the displaypage.jsp at the end...)
 
Mohammad Atiq Kazi
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your replies..

The url will be generated in a dynamic way. We cannot create a separate directory for each url here. Only a single jsp page handles request and based on the query string passed, it will fetch data from the database and send it to midlet. The url looks like this
http://abc.com/abc.jsp?soId=56&pd=26
I need to shorten this url and make it smaller and meaningful. Here abc.jsp handles all requests.

Regards
Atik
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using friendly URL's doesn't mean you have to use directories. But if you are using a JSP as a front controller it does make things a bit more difficult. If you were using a Servlet, for example, you could map it to something like:

/abc/*

And then you could have a URL like:

/abc/56/26

If the 'soId' always comes first and the 'pd' always comes second that is really easy to parse. Then you just do whatever with those values as you normally would as if they came in on a regular query string. I'd bet you can map a JSP similar to mapping a servlet but its been a while since I've done that so I'd have to go digging myself. But that does shorten your URL and makes it meaningful:

http://abc.com/abc/56/26/
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Making query data part of the URL as in the GET example where "abc" addresses a servlet and the numbers are submitted data:

/abc/56/26



is the REST approach to using standard HTTP for web services.
Sun is supporting the open-source Jersey project for the server side of RESTful web services. Here is my simple article on an example.

Jersey uses Java annotations to take care of parsing that URL for you.

Bill
 
No one can make you feel inferior without your consent - Eleanor Roosevelt. tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic