This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Whats wrong with this line of code???

 
Annemarie McKeown
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I get the following values from the database:
String topicid = rs.getString("topicid");
String title = rs.getString("title");
And I can display these in broswer ok, simply out.print("topicd"); etc...
However when I want to print out the title, and make it a link to open up a new jsp page displayTopic.jsp?topicid='"+topicid+"' ( from resultSet rs),
it doesn't seem to display the title as a link properly in the browser.
Can anyone spot any obvious errors in the following line of code:
out.print("<td width='60%'><a href='displayTopic.jsp?topicid='"+topicid+"' '>" + title + "</a></td>");
Some help please....???
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34681
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Annmarie,

Note that these two pieces of code are different. The first displays the six letters "topicd". The second prints the value of the variable topicd. You want the second one to make sure the variable contains what you want it to.
 
Annemarie McKeown
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry my mistake I should have actually written out.print(topicid);
Thats not where my problem is though, something within the long line code out.print("<td>".........
is not displaying in the browser as it should.
I want it to display
title as a link, the user can click on title which will open a new page, passing topicid (?topicd=topicid).
Do you know whats wrong with that line of code.?
 
Adrian Pang
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want topicid=xxx, don't u want
out.println("<td width='60%'><a href='displayTopic.jsp?topicid="+topicid+"'>"...)
instead of:
out.print("<td width='60%'><a href='displayTopic.jsp?topicid='"+topicid+"' >");'>" + title + "</a></td>
(you have an extra ' in the code originally)
which gives you
topicid='xxx' ?
perhaps you should just right click on the link (if you are using IE) and copy shortcut so you can tell what the link points to?
Adrian
[ March 07, 2004: Message edited by: Adrian Pang ]
[ March 07, 2004: Message edited by: Adrian Pang ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic