| Author |
Whats wrong with this line of code???
|
Annemarie McKeown
Ranch Hand
Joined: Nov 07, 2003
Posts: 47
|
|
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
internet detective
Marshal
Joined: May 26, 2003
Posts: 26201
|
|
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.
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
Annemarie McKeown
Ranch Hand
Joined: Nov 07, 2003
Posts: 47
|
|
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
Joined: Feb 20, 2004
Posts: 40
|
|
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 ]
|
SCJP 1.4, SCWCD 1.4, SCBCD 1.3
|
 |
 |
|
|
subject: Whats wrong with this line of code???
|
|
|