Meaningless Drivel is fun!*
The moose likes JSP and the fly likes Passing the data between the site through URL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Passing the data between the site through URL " Watch "Passing the data between the site through URL " New topic
Author

Passing the data between the site through URL

tyte kyat
Ranch Hand

Joined: May 17, 2011
Posts: 40


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.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

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?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
tyte kyat
Ranch Hand

Joined: May 17, 2011
Posts: 40
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
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

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:

Mary Chellapa
Ranch Hand

Joined: Jul 26, 2011
Posts: 93
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?


Mary
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

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

Joined: Jul 26, 2011
Posts: 93
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
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

That greatly depends on what exactly "it" is.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing the data between the site through URL
 
Similar Threads
JavaScript Code Help Required
iBatis and Bidirectional Association
In the messages module reply is not working
Need to split up servlet
How to extract columns of coordinate values from text file (in java) ?