This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes JSP and the fly likes query string Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "query string" Watch "query string" New topic
Author

query string

Astha Sharma
Ranch Hand

Joined: Oct 15, 2011
Posts: 249

Hi
I am using gethod getParameter() for getting parameters from query string, but I think this method is not fetching parameters in my code. getParameter() should return null in first request and value of counter i.e. 1 or -1 in second request, but it is returning null in second request also. Need help, please check my code.

Thanks in advance.


Astha - OCPJP 6 (90%)
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61457
    
  67

What does the HTML for the links look like when rendered at the browser? Are they properly formed on the browser page?

P.S. I hope that this is just test code. The time to be putting Java code in a JSP is long long passed!


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Astha Sharma
Ranch Hand

Joined: Oct 15, 2011
Posts: 249

yes, links are formed properly and I am learning JSP. Its just a test code.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61457
    
  67

Astha Sharma wrote:yes, links are formed properly

Don't tell us. Show us.
Astha Sharma
Ranch Hand

Joined: Oct 15, 2011
Posts: 249

Bear Bibeault wrote:
Astha Sharma wrote:yes, links are formed properly

Don't tell us. Show us.

I am not getting you. Please tell me how can i show you that?
This is the content of output page-
0 next previous
next and previous are links to the same jsp page with parameters counter=<%=count+1%> and counter=<%=count-1%> respectively.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61457
    
  67

That's what's beng sent to the browser? If so, your JSP isn't getting presley evaluated.
Astha Sharma
Ranch Hand

Joined: Oct 15, 2011
Posts: 249

Is there any mistake in my jsp code?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61457
    
  67

Well, you shouldn't be using Java code in a JSP anymore. That's a practice that was discredited 10 years ago. 10 years!

But if the JSP is not being evaluated its more likely a configuration problem.
Astha Sharma
Ranch Hand

Joined: Oct 15, 2011
Posts: 249

ok...thanks for the reply.
sagar kumar nerella
Greenhorn

Joined: Jul 09, 2011
Posts: 18

i think you should use the EL expression support .
instead of using counter=count+1 use ${count} +1

i think it solves your problem


sagar kumar nerella,
java certified professional
Astha Sharma
Ranch Hand

Joined: Oct 15, 2011
Posts: 249

Hi sagar
thanks for the reply, but actually the mistake was in the link which i was using in this code :banghead:
now i got the mistake and am getting correct output :beerchug:
sagar kumar nerella
Greenhorn

Joined: Jul 09, 2011
Posts: 18

Astha Sharma wrote:Hi sagar
thanks for the reply, but actually the mistake was in the link which i was using in this code :banghead:
now i got the mistake and am getting correct output :beerchug:


ok then can you show me how you solved the problem i.e what modification you did
Astha Sharma
Ranch Hand

Joined: Oct 15, 2011
Posts: 249

sagar kumar nerella wrote:ok then can you show me how you solved the problem i.e what modification you did

this is the modified code-

Previously I was using wrong url in anchor tag
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: query string