Solved

What to do with qoutes inside qoutes.

Posted on 2001-08-17
5
313 Views
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>   ");

Thanks.
-Dsys
0
Comment
Question by:Dsys
  • 3
  • 2
5 Comments
 
LVL 5

Accepted Solution

by:
aryumin earned 50 total points
Comment Utility
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>");
0
 

Author Comment

by:Dsys
Comment Utility
aryumin,

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.

-Dsys
0
 
LVL 5

Expert Comment

by:aryumin
Comment Utility
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.
0
 

Author Comment

by:Dsys
Comment Utility
aryumin.

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: http://entercite.com:82/examples/servlet/ShowGroup

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.io.*;
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
            try
            {
                  
                  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");

                  response.setContentType("text/html");
                  PrintWriter out = response.getWriter();

                  out.println("<HTML>");
                  out.println("<HEAD><TITLE>Pictures</TITLE>");
                  out.println("<style>");
                  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.post:hover{color:#000000;}");
                  out.println("      a.black{color:#000000;}");
                  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("</style>");
                  out.println("<script LANGUAGE=\"JavaScript\" TYPE=\"text/javascript\" src=\"e.js\"></script>");
                  out.println("</HEAD>");
                  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("</table>");
                  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>");
                  out.println("<BR>");
                  out.println("<!---Header--->");
                  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("<!---Member--->");
                  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("</table>");
                  out.println("<center>");
                  out.println("<!------Legal links -->");
                  out.println("<em class=\"txt8\"><a href=\"legal-notice.html\">Legal Notice</a>  ? 2000 Site.</em>");
                  out.println("</center>");
                  out.println("</body>");
                  out.println("</html>");


            }
            catch (IOException e)
            {
                  System.out.println(e);
            }

            catch (Exception e)
            {
                  log.logInfo("New Error : " + e.getMessage());
                          e.printStackTrace();
            }      
      }
}
0
 
LVL 5

Expert Comment

by:aryumin
Comment Utility
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.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
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…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
The viewer will learn how to implement Singleton Design Pattern in Java.

771 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now