Solved

Java dynamic html href

Posted on 2014-10-09
5
163 Views
Last Modified: 2014-10-09
I am trying to decipher someone elses undocumented code.

I do know that the following statement is designed to render a hyperlink on a line.

String myURL= “HTTP://MySite.com”;
out.println("<li class=\"\"><a href=\""+myURL+"/Help/Contact/front.cfm?fromJSP=1\" title=\"PMS385\">PMS385</a></li>");

What is the HTML that this statement renders?

Thanks,
0
Comment
Question by:Dovberman
  • 2
  • 2
5 Comments
 
LVL 76

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points
ID: 40370653
Unescape the '"' and replace the string and I get:
<li class=""><a href="HTTP://MySite.com/Help/Contact/front.cfm?fromJSP=1" title="PMS385">PMS385</a></li>

Open in new window

0
 

Author Comment

by:Dovberman
ID: 40370759
Now it is clear.  The \" represents the "  character.

thanks,
0
 

Author Closing Comment

by:Dovberman
ID: 40370761
Thank you,
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 40370773
>>Now it is clear.  The \" represents the "  character.

It is 'escaping' the next character.

Java interprets the " as a string delimiter.  To have one inside a string you 'escape' it.

http://docs.oracle.com/javase/tutorial/java/data/characters.html

Escape Sequences

A character preceded by a backslash (\) is an escape sequence and has special meaning to the compiler. The following table shows the Java escape sequences:
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
This article discusses four methods for overlaying images in a container on a web page
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question