Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HREF in servlets..... errrrrrrrrrrr frustrated....

 
c cannata
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the piece of code I have been hacking on for some time now.


Currently..... I have this.... and it works... it
returns stuff from the database...

public void printCategories(HttpServletRequest request, HttpServletResponse response, String trade, int x, String[]
pslLevelTwoCategories, PrintWriter out) throws IOException

out.println("<B <INPUT TYPE=\"RADIO\" NAME=radio1 VALUE=" + pslLevelTwoCategories[y] + " " + pslLevelTwoCategories[y] + "</a <br ");


This is what I would like it to do...

out.println("<a href=\"http://localhost:8000/servlets/MainSearch?=\" "+ pslLevelTwoCategories[y] +" " + pslLevelTwoCategories[y] + "</a <br ");


For the life of me I cannot get the params correct in the href and I keep getting a error message of not found etc. If you are interested in helping me with this I can send you the entire piece of code, but for this it's just really short.
Thanks
Chris
 
Maky Chopra
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what should your url look like ? And what text do you need hyperlinked ?
 
Maky Chopra
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"c cannata",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements.
Thanks.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13056
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
out.println("<a href=\"http://localhost:8000/servlets/MainSearch?=\" "+
pslLevelTwoCategories[y] +" " + pslLevelTwoCategories[y] + "</a <br ");
It looks to me like that code will write a quote just
after ?= so the href will not include your data from
the categories. Also I think you want just ? not ?=.
Debugging tip: Do a view source of the form page whenever you dont get the expected results from a form.
Bill

------------------
author of:
 
maha anna
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A sample href link is here.
<a href="http://localhost/MISApp/welcome.jsp?login=yourName&password=yourPasswd"> Click here </a>
regds
maha anna
 
c cannata
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess what I am asking is in you outprint statment what would you put if you currently had this.

out.println("<B <INPUT TYPE=\"RADIO\" NAME=radio1 VALUE=" + pslLevelTwoCategories[y] + " " + pslLevelTwoCategories[y] + "</a <br ");
and you wanted a href instead. What code would I write to make this into a url instead of a toggle button. I have tried multiple ways and nothing seems to work. I am just tired of people complaining to me that they cannot see the submit button at the bottom of the page.
cc

Originally posted by maha anna:
A sample href link is here.
<a href="http://localhost/MISApp/welcome.jsp?login=yourName&password=yourPasswd"> Click here </a>
regds
maha anna

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic