Link to home
Start Free TrialLog in
Avatar of Dsys
Dsys

asked on

What to do with qoutes inside qoutes.

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
ASKER CERTIFIED SOLUTION
Avatar of aryumin
aryumin
Flag of Russian Federation image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dsys
Dsys

ASKER

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
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.
Avatar of Dsys

ASKER

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();
            }      
      }
}
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.