• Post Reply Bookmark Topic Watch Topic
  • New Topic

please help  RSS feed

 
dhriti joshi
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can anybody tell what does follo. syntax mean
String link="bottom.jsp?folderId=5000&ID="+(String)session.getValue("ID");
which operator is this "? &"
dhriti
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The "?" and the "&" are both inside a double quoted string literal -- i.e., as far as Java is concerned, they're just meaningless text. Formatting the code like this might help to see this:
String link = "bottom.jsp?folderId=5000&ID=" + (String)session.getValue("ID");
(I just added a few spaces.)
Now, to give you a little more information than you asked for, it looks like the String that's being built up is part of a URL. These characters are standard way of formatting parameters sent to a Web app. First you have the name of the program itself (here it's bottom.jsp). Then you have a "?" character. Then you have a series of name/value pairs that serve as parameters. Here you've got names "folderId" and "ID", and values "5000" and whatever the session.getValue() call returns. The name/value pairs are separated by "&" characters.
 
Sadanand Murthy
Ranch Hand
Posts: 382
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ernest Friedman-Hill:
The "?" and the "&" are both inside a double quoted string literal -- i.e., as far as Java is concerned, they're just meaningless text. Formatting the code like this might help to see this:
String link = "bottom.jsp?folderId=5000&ID=" + (String)session.getValue("ID");
(I just added a few spaces.)
Now, to give you a little more information than you asked for, it looks like the String that's being built up is part of a URL. These characters are standard way of formatting parameters sent to a Web app. First you have the name of the program itself (here it's bottom.jsp). Then you have a "?" character. Then you have a series of name/value pairs that serve as parameters. Here you've got names "folderId" and "ID", and values "5000" and whatever the session.getValue() call returns. The name/value pairs are separated by "&" characters.

Dhriti, also note that all parameters that are passed to a URL in the URL string itself must be String. That is why session.getValue("ID") is being cast to String.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sadanand Murthy:

Dhriti, also note that all parameters that are passed to a URL in the URL string itself must be String. That is why session.getValue("ID") is being cast to String.


Actually, session.getValue("ID") is being cast to a String because the original programmer doesn't know Java very well; the cast is not necessary.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!