• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Passing the data between the site through URL

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


can someone please explain me the difference between the above two lines?

As far as I understand, line no 5 does not use script-let, so it does not need to use "out.println" and so (" .... ");
So, the remaining, <a herf="idtest_2.jsp?ida="+variable> is fine . I THINK.

But, it is showing "null". When I try to get the value by using -->request.getParameter("ida");

so, please someone point out my mistake or misunderstanding.

Line no 6 is working fine it is passing the variable. But not line no 5.
Thanks.
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In 2011 there should no longer be any Java code in a JSP. JSP 2 was introduced almost 10 years ago and the JSTL and EL should be used in place of Java code.

Using out.println() in a Java script let is an especially horrible practice. The whole point of a JSP is to serve as an HTML template. Building HTML inside a Java string, inside a scriptlet, inside a JSP is simply awful -- even for JSP 1 code.

What is it you're really trying to accomplish?
 
tyte kyat
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the quick reply...

I want to pass a variable to another JSP page, which is linked using <a href=" "> </a> anchor tag.
 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Right, you'd do that using an <a> tag and passing the value as a request parameter.

So let's say that you had the value to pass in a scoped variable named xyz and you wanted to pass it using the name abc, you do that with:

 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ans and Q :

Cant we use redirect instead of <a>
or hidden parameter(then url wont be used) ... if you have to pass a value to next jsp?
 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mary Chellapa wrote:Cant we use redirect instead of <a>


No, a redirect happens immediately. An anchor tag needs to be clicked upon.

or hidden parameter(then url wont be used)


The OP specifically asked about a link. But sure, a hidden (or even non-hidden) parameter can be used for a form submission. And whether the URL is "used" or not depends upon the HTTP method used.
 
Mary Chellapa
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:No, a redirect happens immediately. An anchor tag needs to be clicked upon.



Bear,

any other way ( than <a> ) can it be done.

 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That greatly depends on what exactly "it" is.
 
reply
    Bookmark Topic Watch Topic
  • New Topic