What to do with qoutes inside qoutes.

Posted on 2001-08-17
Last Modified: 2013-11-24
Hello all,
When creating my HTML from my servlet, I have some JavaScript I run into. It has some double qoutes in it. How can I write this out correctly?

out.println("   <a href='/info/Home.html' onmouseover="hlight('HOME')" onmouseout="norm('HOME')">
<img src='../cimage/Home.gif' border='0' name='HOME' alt='Websites'></a>   ");

Question by:Dsys
  • 3
  • 2

Accepted Solution

aryumin earned 50 total points
ID: 6396615
out.println("<a href=\"/info/Home.html\" onmouseover=\"hlight('HOME')\" onmouseout=\"norm('HOME')\">
<img src=\"../cimage/Home.gif\" border=\"0\" name=\"HOME\" alt=\"Websites\"></a>");

Author Comment

ID: 6399025

Yeah that compiles now. One problem I am having is that is part of a JavaScript. It uses a .js file for the other part of the script. When I mouse over the buttons, events occur but they are causing errors. I am going to try a few more things with it but so far I am stuck.

Have you ever embeded javascript like simple mouse over button type stuff within your output from a servlet? Could I show you some more of my code and maybe you could see what is wrong?

I am using port 8080 when I write out the page. Should I change the output somehow to port 80? Maybe that is part of the trouble because the class file is not located in the www folder and it cannot find the images.


Expert Comment

ID: 6405150
Can you access your images and js directly (via typing it's urls in browser)?
If you use relative paths for it (like <script src="../script.js"> and <img src="../image.gif">, not http://....) - don't worry about port.

Author Comment

ID: 6408827

Well let see how to begin. I have tried to define file locations like you say but any links have to have the full path or else they are not found. This is because the servelt runs on a different port number than IIS. Another wierd thing is some images show up and others do not even though all the images are in the same folder and the names are correct and the permissions are identical???

One of the problems I run into is that the javascript when attempting to execute a mouse over event it fails.

Here is a link to my servlet:

Here is the source code to the servlet. It is mostly just generation of the webpage... hopefully you will comment on your ideas when you view what I am doing in code.

import java.util.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class ShowGroup extends HttpServlet {

      public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws IOException, ServletException
            Log log = null;

            //Set up DB connection
                  log = new Log("C:/jsdk2.1/examples/servlets/oob.log");

                  System.out.println("passed 1");
                   * show the fixes that occured.
                   * make the cnfr a link to the items actual events.
                    * generate the info from the table log.

                  log.logInfo("Begin Reading files");

                  PrintWriter out = response.getWriter();

                  out.println("      a{text-decoration:none;color:#526bff}");
                  out.println("      a:hover{text-decoration:underline;color:#0428de}");
                  out.println("      a.menuitem{text-decoration:none;font:8pt verdana;color:#e9e9e9}");
                  out.println("      a.empitem{text-decoration:none;font:8pt verdana;color:#d69c21}");
                  out.println("      a.menuitem:hover{text-decoration:underline;font:8pt verdana;color:#FFFFFF}");
                  out.println("      a.empitem:hover{text-decoration:underline;font:8pt verdana;color:#FFFFFF}");
                  out.println("      a.blackmenuitem{text-decoration:none;font:bold 8pt verdana;color:#000000}");
                  out.println("      a.blackmenuitem:hover{text-decoration:none;font:bold 8pt verdana;color:#FFFFFF}");
                  out.println("      a.dvdline{font:8pt verdana;color:#000000}");
                  out.println("      a:hover.dvdline{font:8pt verdana;color:#000000}");
                  out.println("      a.memb{color:#3b4b9b;text-decoration:none}");
                  out.println("      a.memb:hover{color:#526bff;text-decoration:none}");
                  out.println("      a.ftrial{font:8pt verdana;text-decoration:none}");
                  out.println("      a.ftrial:hover{color:red;text-decoration:none}");
                  out.println("      .pagedesc{font-family:verdana;font-size:10pt}");
                  out.println("      .bgi{background-image: url(/cw_gifs/bannerImages/menugray.gif)}");
                  out.println("      .pt8{font:8pt verdana}");
                  out.println("      .bold8pt{font:bold 8pt verdana}");
                  out.println("      .pt10{font:10pt verdana}");
                  out.println("      .bold10pt{font:bold 10pt verdana}");
                  out.println("      .pt12{font:12pt verdana}");
                  out.println("      .bold12pt{font:bold 12pt verdana}");
                  out.println("      .pt8gold{font:8pt verdana;color:d69c21}");
                  out.println("      .boldpt12gold{font:bold 12pt verdana;color:d69c21}");
                  out.println("      .redbold10pt{font:bold 10pt verdana;color:red}");
                  out.println("<script LANGUAGE=\"JavaScript\" TYPE=\"text/javascript\" src=\"e.js\"></script>");
                  out.println("<body topmargin=0 leftmargin=0 marginheight=0 marginwidth=0>");
                  out.println("<table width=300 cellpadding=0 cellspacing=0 border=0 >");
                  out.println("      <tr>");
                  out.println("            <td><img src=\"/image/ETitle.gif\" height=50 width=290></td>");
                  out.println("      </tr>");
                  out.println("<!--Top Menu-->");
                  out.println("<table cellpadding=0 cellspacing=0 width=100% border=0>");
                  out.println("      <tr>");
                  out.println("            <table cellpadding=0 cellspacing=0 width=100% border=0>");
                  out.println("                  <tr valign=top>");
                  out.println("                        <td colspan=2 bgcolor=#454544>");
                  out.println("                        <table class=bgi cellpadding=1 cellspacing=0 width=100% border=0 align=center>");
                  out.println("                              <tr>");
                  out.println("                                    <td align=center><a class=menuitem href=\"javascript:pop_help('/home/popup/comment.html');\" onMouseOver=\"HM_f_PopUp('elMenu1',event)\" onMouseOut=\"HM_f_PopDown('elMenu1')\">Comments</a></td>");
                  out.println("                                    <td align=center><a class=menuitem href=\"javascript:pop_help('/home/popup/tutorial.html');\" onMouseOver=\"HM_f_PopUp('elMenu4',event)\" onMouseOut=\"HM_f_PopDown('elMenu4')\">Tutorial</a></td>");
                  out.println("                                    <td align=center><a class=menuitem href=\"javascript:pop_help('/home/popup/contact.html');\" onMouseOver=\"HM_f_PopUp('elMenu4',event)\" onMouseOut=\"HM_f_PopDown('elMenu4')\">Contact Us</a></td>");
                  out.println("                                    <td align=center><a class=empitem href=\"javascript:pop_help('/home/popup/employment.html');\" onMouseOver=\"HM_f_PopUp('elMenu5',event)\" onMouseOut=\"HM_f_PopDown('elMenu5')\">Employement</a></td>");
                  out.println("                                    <td align=right>");
                  out.println("                                          <table cellpadding=1 cellspacing=0 border=0 bgcolor=#000000>");
                  out.println("                                                <tr>");
                  out.println("                                                      <td bgcolor=#d69c21 width=13 align=center><a class=blackmenuitem ");
                  out.println("                                                      href=\"javascript:pop_help('/home/popup/help.html');\" onMouseOver=\"HM_f_PopUp('elMenu6',event)\" onMouseOut=\"HM_f_PopDown('elMenu6')\">?</a></td>");
                  out.println("                                                </tr>");
                  out.println("                                          </table>");
                  out.println("                                    </td>");
                  out.println("                              </tr>");
                  out.println("                         </table>");
                  out.println("                        </td>");
                  out.println("                  </tr>");
                  out.println("            </table>");
                  out.println("      </tr>");
                  out.println("<table width=100% cellpadding=2 cellspacing=0 border=0 bordercolor=#000000>");
                  out.println("      <tr>");
                  out.println("            <td align=left valign=top width=17% class=bgsixth>");
                  out.println("            <table class=dbb76b width=140 border=1 cellspacing=0 cellpadding=2>");
                  out.println("<!---Left Menu--->");
                  out.println("                  <td align=center bgcolor=#9999CC colspan=2><font face=arial size=2 font color=#ffffff ><b>Main Menu</b></font></td>");
                  out.println("                        <tr>");
                  out.println("                              <td colspan=0 width=140>");
                  out.println("                                    <table cellpadding=2 cellspacing=0 border=0>");
                  out.println("                                          <tr>");
                  out.println("                                                <td width=140>");
                  out.println("                                                      <span style='font-size:10pt;text-decoration:none;text-underline:none'>");
                  out.println("                                                            <a href=\"/Home/Home.html\" onmouseover=\"hlight('HOME')\" onmouseout=\"norm('HOME')\"> ");
                  out.println("                                                            <img src=\"../image/Home.gif\" border=0 name=\"HOME\" alt=\"Websites\"></a> ");
                  out.println("                                                            <a href=\"/Home/info.html\" onmouseover=\"hlight('INFO')\" onmouseout=\"norm('INFO')\"> ");
                  out.println("                                                            <img src=\"../image/info.gif\" border=0 name=\"INFO\" alt=\"General Information\"></a> ");
                  out.println("                                                            <a href=\"/Home/News.html\" onmouseover=\"hlight('UPDATES')\" onmouseout=\"norm('UPDATES')\"> ");
                  out.println("                                                            <img src=\"../image/updates.gif\" border=0 name=\"UPDATES\" alt=\"Server Updates\"></a> ");
                  out.println("                                                      </span>");
                  out.println("                                                </td>");
                  out.println("                                          </tr>");
                  out.println("                                        </table>");
                  out.println("                              </td>");
                  out.println("                        </tr>");
                  out.println("                        <tr>");
                  out.println("                              <td align=center bgcolor=#6699CC colspan=2>");
                  out.println("                                      <font face=arial size=2 font color=#ffffff ><b>Entercite Members</b></font>");
                  out.println("                               </td>");
                  out.println("                         </tr>");
                  out.println("                         <tr>");
                  out.println("                               <td colspan=2>");
                  out.println("                                      <table cellpadding=2 cellspacing=0 border=0>");
                  out.println("                                              <tr>");
                  out.println("                                                    <td width=140> ");
                  out.println("                                                      <span style='font-size:10pt;text-decoration:none;text-underline:none'>");
                  out.println("                                                            <a href=\"/Home/login.html\" onmouseover=\"hlight('LOGIN')\" onmouseout=\"norm('LOGIN')\"> ");
                  out.println("                                                             <img src=\"../image/Login.gif\" border=0 name=\"LOGIN\" alt=\"Login page\"></a> ");
                  out.println("                                                            <a href=\"/Home/logoff.html\" onmouseover=\"hlight('LOGOFF')\" onmouseout=\"norm('LOGOFF')\"> ");
                  out.println("                                                            <img src=\"../image/LOGOFF.gif\" border=0 name=\"LOGOFF\" alt=\"Log off\"></a> ");
                  out.println("                                                            <a href=\"/Home/member.html\" onmouseover=\"hlight('SIGNUP')\" onmouseout=\"norm('SIGNUP')\"> ");
                  out.println("                                                            <img src=\"../image/SIGNUP.gif\" border=0 name=\"SIGNUP\" alt=\"Register as a member\"></a> ");
                  out.println("                                                      </span>");
                  out.println("                                                </td>");
                  out.println("                                          </tr>");
                  out.println("                                    </table>");
                  out.println("                              </td>");
                  out.println("                        </tr>");
                  out.println("<!---Site Information--->");
                  out.println("                        <tr> ");
                  out.println("                              <td align=center td bgcolor=#336699 colspan=2>");
                  out.println("                                    <font face=arial size=2 font color=#ffffff ><b>Site Information</b></font>");
                  out.println("                              </td>");
                  out.println("                        </tr>");
                  out.println("                        <tr>");
                  out.println("                              <td colspan=2>");
                  out.println("                                    <table cellpadding=2 cellspacing=0 border=0><tr>");
                  out.println("                                          <td width=140>");
                  out.println("                                                <span style='font-size:10pt;text-decoration:none;text-underline:none'>  ");
                  out.println("                                                      <a href=\"/Home/Products.html\" onmouseover=\"hlight('Prod')\" onmouseout=\"norm('Prod')\"> ");
                  out.println("                                                      <img src=\"../image/Products.gif\" border=0 name=\"Prod\" alt=\"Product list\"></a> ");
                  out.println("                                                      <a href=\"/Home/Advertise.html\" onmouseover=\"hlight('Adver')\" onmouseout=\"norm('Adver')\"> ");
                  out.println("                                                      <img src=\"../image/Advertise.gif\" border=0 name=\"Adver\" alt=\"Advertise\"></a> ");
                  out.println("                                                      <a href=\"/Home/links.html\" onmouseover=\"hlight('Links')\" onmouseout=\"norm('Links')\"> ");
                  out.println("                                                      <img src=\"../image/Links.gif\" border=0 name=\"Links\" alt=\"Links\"></a> ");
                  out.println("                                                </span>");
                  out.println("                                          </td>");
                  out.println("                                    </table>");
                  out.println("                              </td>");
                  out.println("                        </tr>");
                  out.println("            </table>");
                  out.println("<!---Middle Theme section--->");
                  out.println("      <td valign=left width=100% > ");
                  out.println("<!-----Middle section------------>");
                  out.println("      <TABLE width=100% borderColor=#003399 cellSpacing=0 cellPadding=5 border=1>");
                  out.println("            <TR>");
                  out.println("                  <TD>");
                  out.println("                        <TABLE cellSpacing=0 cellPadding=0 width=100% border=0>");
                  out.println("                              <TR>");
                  out.println("                                    <TD width=100%>");
                  out.println("                                          <DIV align=center><FONT style=\"FONT-SIZE: 18px\" color=#003399><B>Home</B></FONT> </DIV><BR>");
                  out.println("                                          <HR style=\"COLOR: #003399; HEIGHT: 3px\" width=100%><BR>");
                  out.println("                                          <FONT style=\"FONT-SIZE: 16px\" color=#336699><B>Sites.</FONT>");
                  out.println("                                          <font size=2 face=arial></B>");
                  out.println("                                          These pages are just demo pages.  ");
                  out.println("                                    </TD>");
                  out.println("                              </TR>");
                  out.println("                              <TR>");
                  out.println("                                    <TD>");
                  out.println("                                          1. <a href=\"../home/Java.html\">Java servlet page</a></b> ");
                  out.println("                                          2. <a href=\"../store/site.html\">Flash demo</a></b>");
                  out.println("                                          <BR><BR><BR><BR><BR><BR><BR><BR>");
                  out.println("                                    </TD>");
                  out.println("                              </TR>");
                  out.println("                        </TABLE>");
                  out.println("                  </TD>");
                  out.println("            </TR>");
                  out.println("      </TABLE>");
                  out.println("<!------Legal links -->");
                  out.println("<em class=\"txt8\"><a href=\"legal-notice.html\">Legal Notice</a>  ? 2000 Site.</em>");

            catch (IOException e)

            catch (Exception e)
                  log.logInfo("New Error : " + e.getMessage());

Expert Comment

ID: 6519012
The URL is a case-sensitive.
So, the ETitle.gif doesn't exists on your server, but etitle.gif does :)
And check the path and name for your e.js file are correct.

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…

726 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