Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Sending request parameters from a JSP page  RSS feed

 
Alyssa Kay
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I haven't been able to pass through request parameters when they are aren't a fixed value. I have searched the web etc with no success.

<a href="Controller?action=summary&id=pid"><% out.println(obj.getProductName()); %> </a>

I am trying to pass an id to a servlet from a jsp page, when a link is selected. Depending on which link is selected the id changes.

The value of pid is comes from:

String pid = obj.getKey();

I have tried :

- ?action=summary&id=pid">
- ?action=summary&id=" +pid>


If you can help please post a response!


Thanks Alyssa

 
Shailesh Narkhede
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Alyssa,

You can do this by,
Expression but In 2009 you should not use old era Expressions(<%=obj.getKey()%>)
You can use EL Put obj in propare scope(request,session, etc) & use ${obj.key}

 
Alyssa Kay
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

So the way I have tried to implement this is incorrect?

I understand it is not the current implemention, although it is the only way that I have been able to call a servlet only when a link has been clicked, using URL request parameters.

Is it possible to do a request.put when a link has been selected?

Thanks, Alyssa
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66203
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. Browsers do not generate PUT requests (unless you decide to use Ajax).

That doesn't seem to have much to do with your original question. Perhaps you should back up and explain what you are trying to accomplish?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would start by examining the text of the HTML page being generated with browser side "view source."

If you find that the URL in the link has the form you expect then the server side doGet is not extracting the parameter correctly.

It is entirely reasonable to construct a static HTML page with a correctly formatted URL link to use in debugging the servlet.

Bill
 
Alyssa Kay
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Thanks for your responses.

I have found request.getParameter from the servlet is returning the variables name instead of its value.

This is how I call the servlet from the jsp.



I require the serlvet to run only when the link is selected. Once the link is selected it will call the servlet to retrieve the information for the data. The reason behind this is I have a large tree of data which is populated dynamically.



Is this the correct approach?

Thanks all.

Cheers Alyssa.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66203
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using out.println() like that is really weird.

When you do a VIew Source and inspect the structure of the link, is it correct?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!