473,786 Members | 2,375 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

getElementById( "results").inne rHTML = message has no properties

2 New Member
Hello,

I have been having this problem for the whole day today, so even after i googled for the solution i was not able to get one, so i had to post to this forum. I had checked the solutions suggested on this forum but its not working for me still.

Ok I would start from the beginning:


Plastform:
---------------
MAC OS X 10.5.2
Netbeans IDE 6.0.1
Glassfish V2UR1
MySQL 5.0
Firefox


Code:

1> I have an enterprise application in the NetBeans and basically i am trying to create a web 2.0 based project in which the user when he/she inputs the username they are immediately informed if the userid is available or not.

JSP code:
---------------
Expand|Select|Wrap|Line Numbers
  1. <%-- 
  2.     Document   : UserSignOn
  3.     Created on : Mar 13, 2008, 4:07:08 PM
  4.     Author     : ankittoshniwal
  5. --%>
  6.  
  7. <%@page contentType="text/html" pageEncoding="UTF-8"%>
  8.  
  9.  
  10.  
  11. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  12. "http://www.w3.org/TR/html4/loose.dtd">
  13.  
  14. <html>
  15.     <head>
  16.         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
  17.         <title>User Sign On</title>
  18.         <script language="javascript">
  19.             var xmlHttp; 
  20.  
  21.             function createXmlHttpRequest() 
  22.             {
  23.                 try
  24.                 {
  25.                     xmlHttp = new XMLHttpRequest();
  26.  
  27.                 } catch (tryMicrosoft)
  28.                 {
  29.                     try {
  30.                         xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
  31.                     }
  32.                     catch (otherMicrosoft)
  33.                     {
  34.                         try
  35.                         {
  36.                             request = new ActiveXObject("Microsoft.XMLHTTP");
  37.                         }catch (failed)
  38.                         {
  39.                             xmlHttp = false;
  40.                         }
  41.                     }
  42.                 }
  43.  
  44.                 if (!xmlHttp)
  45.                     alert("error initializing XMlHttpRequest");
  46.             }
  47.             function callServer() 
  48.             {
  49.  
  50.                 createXmlHttpRequest();
  51.                 // var nameValue = document.getElementById("n");
  52.                 var userNameValue = document.getElementsByName("user").value;
  53.  
  54.                 var url = "/TestProject-war/data?tempUserName=" + escape(userNameValue);
  55.  
  56.                 xmlHttp.open("GET", url, true);
  57.  
  58.                 xmlHttp.onreadystatechange = confirmUpdate;
  59.  
  60.                 xmlHttp.send(null);
  61.  
  62.             }
  63.  
  64.             function confirmUpdate() 
  65.             {
  66.  
  67.                 if (xmlHttp.readyState == 4)
  68.                     {
  69.                         if (xmlHttp.status == 200)
  70.                             {
  71.  
  72.                                 var message =  
  73.                                 xmlHttp.responseXML
  74.                                 .getElementsByTagName("valid")[0]
  75.                                 .childNodes[0].nodeValue;
  76.  
  77. // Basically this is the point which is giving me errors
  78.                  document.getElementById("results").innerHTML = message;
  79.  
  80.                             }
  81.                             else
  82.                                 {
  83.                                     alert("Error loading page" + xmlHttp.status );
  84.                                 }
  85.                             }
  86.  
  87.  
  88.                         }
  89.         </script>
  90.  
  91.     </head>
  92.     <body>
  93.  
  94.         <p> We are trying to read</p>
  95.         <input type="text" onkeyup="callServer();"/>
  96.          <td width="31%" id=”results”>&nbsp;</td>
  97.  
  98.     </body>
  99. </html>
  100.  
Servlet Code:
--------------------
So what i was planning to do was get the input from the JSP page and transfer it to the Servlet. In the servlet i was trying to connect to database and get the username approved, but i was getting the same errors, and hence i deleted the whole code and i just wrote a simple code in which whatever might be the input by the user in the JSP page the servlet would return "true" from the servlet meaning the username is true and available.

Code is as follows:
Expand|Select|Wrap|Line Numbers
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5.  
  6. package org.web;
  7.  
  8. import java.io.*;
  9. import java.net.*;
  10. import java.math.*;
  11.  
  12. import java.util.List;
  13. import java.util.ListIterator;
  14. import javax.ejb.EJB;
  15. import javax.servlet.*;
  16. import javax.servlet.http.*;
  17. import org.ejb.UserDetailsFacadeLocal;
  18. import org.ejb.UserDetails;
  19.  
  20. /**
  21.  *
  22.  * @author ankittoshniwal
  23.  */
  24. public class data extends HttpServlet {
  25.     @EJB
  26.     private UserDetailsFacadeLocal userDetailsFacade;
  27.  
  28.    String tempUsr;
  29.    String tempUsername;
  30.    String tempId;
  31.     /** 
  32.     * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
  33.     * @param request servlet request
  34.     * @param response servlet response
  35.     */
  36.     protected void processRequest(HttpServletRequest request, HttpServletResponse response)
  37.     throws ServletException, IOException {
  38.         response.setContentType("text/html;charset=UTF-8");
  39.         PrintWriter out = response.getWriter();
  40.         try {
  41.             // TODO output your page here
  42.             out.println("<html>");
  43.             out.println("<head>");
  44.             out.println("<title>Servlet data</title>");  
  45.             out.println("</head>");
  46.             out.println("<body>");
  47.             out.println("<h1>Servlet data at " + request.getContextPath () + "</h1>");
  48.             UserDetails UserDetailsObj = new UserDetails();
  49.             out.println("</body>");
  50.             out.println("</html>");
  51.  
  52.         } finally { 
  53.             out.close();
  54.         }
  55.     } 
  56.  
  57.     // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
  58.     /** 
  59.     * Handles the HTTP <code>GET</code> method.
  60.     * @param request servlet request
  61.     * @param response servlet response
  62.     */
  63.     protected void doGet(HttpServletRequest request, HttpServletResponse response)
  64.     throws ServletException, IOException {
  65.  
  66.         PrintWriter out = response.getWriter();
  67.         UserDetails userObj = new UserDetails();
  68.      //   String checkName = request.getParameter("name");
  69.       //  String checkUserName = request.getParameter("user");
  70.        // String temp;
  71.  
  72.                     response.setContentType("application/xml");
  73.                     response.setHeader("Cache-Control", "no-cache");
  74.                     response.getWriter().write("<valid>true</valid>");
  75.     } 
  76.  
  77.     /** 
  78.     * Handles the HTTP <code>POST</code> method.
  79.     * @param request servlet request
  80.     * @param response servlet response
  81.     */
  82.     protected void doPost(HttpServletRequest request, HttpServletResponse response)
  83.     throws ServletException, IOException {
  84.  
  85.         PrintWriter out = response.getWriter();
  86.  
  87.               doGet(request, response);  
  88.        // processRequest(request, response);
  89.     }
  90.  
  91.     /** 
  92.     * Returns a short description of the servlet.
  93.     */
  94.     public String getServletInfo() {
  95.         return "Short description";
  96.     }
  97.     // </editor-fold>
  98. }
----------------------------------------------------------------------

can somebody explain me where i am going wrong, i have been following the IBM's AJAX tutorial but its not helping out.

Any help would be greatly appreciated.

Thanks,
Ankit.
Mar 20 '08 #1
7 3945
gits
5,390 Recognized Expert Moderator Expert
hi ...

could you first try to fix the quotes in your line 96 ... that seems to be strange quotes ...

if that doesn't help next step: could you alert the message-text instead of setting innerHTML? is the alert showing you what you would expect?

kind regards
Mar 20 '08 #2
ankitoshniwal
2 New Member
Hi,

Thanks for the reply.

I did try what you had asked me to, i changed the quotes and now they are,

document.getEle mentById("resul ts").innerHTM L = message;

also when i just alert the message-text i do get the required output but it just wont show it when i pass the command given above.

Thanks,
Ankit.
Mar 21 '08 #3
RamananKalirajan
608 Contributor
Hi,

Thanks for the reply.

I did try what you had asked me to, i changed the quotes and now they are,

document.getEle mentById("resul ts").innerHTM L = message;

also when i just alert the message-text i do get the required output but it just wont show it when i pass the command given above.

Thanks,
Ankit.
Hello Mr. Ankit, it's a suggestion, why can't you try like this
[HTML]
<td><span Id="results"></span></td><br/>[/HTML]

Just try whether it is working or not

Regards
Ramanan Kalirajan
Mar 21 '08 #4
acoder
16,027 Recognized Expert Moderator MVP
I did try what you had asked me to, i changed the quotes and now they are,

document.getEle mentById("resul ts").innerHTM L = message;

also when i just alert the message-text i do get the required output but it just wont show it when i pass the command given above.
Strange that you have a td element without a table tag. Perhaps if you enclose it within a table, it could work.
Mar 22 '08 #5
acoder
16,027 Recognized Expert Moderator MVP
Hello Mr. Ankit, it's a suggestion, why can't you try like this
[HTML]
<td><span Id="results"></span></td><br/>[/HTML]

Just try whether it is working or not
or even without the td element, i.e. just the span element, or a div element. I think that the "Id" should be lowercase, i.e. id="results".
Mar 22 '08 #6
RamananKalirajan
608 Contributor
or even without the td element, i.e. just the span element, or a div element. I think that the "Id" should be lowercase, i.e. id="results".
Thank you for the correction acoder

Regards
Ramanan kalirajan
Mar 24 '08 #7
acoder
16,027 Recognized Expert Moderator MVP
Thank you for the correction acoder
Not necessarily a correction - more improvements/alternatives.
Mar 24 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
24677
by: Dave Hammond | last post by:
I've got what should be a simple assignment of either an element value or a default string to a variable, but when the element doesn't exist I get an "Object required" error rather than an assignment of the default value. I originally used the simple statement: var v = document.getElementById('foo').value || parent.document.getElementById('foo').value || 'unknown';
53
2977
by: Aaron Gray | last post by:
I jokingly say this is the late entry :) Okay I have read all the event entry comments from John's Resig's AddEvent comepition blog :- http://ejohn.org/projects/flexible-javascript-events/ and put together the following offering for my LGPL'ed library functions :- function addEvent( el, type, fn, cascade) {
19
2569
by: bonneylake | last post by:
Hey Everyone, Well i keep getting the error that addInput is not defined but i can not figure out what is wrong with it. It worked perfectly fine when i was using it to submit data. But now that i am trying to make it display previously entered data it says addInput is not defined. could really use an idea on whats wrong with it because i can't figure it out. here is what i have javascript <script type="text/javascript"> function...
1
1600
by: DelphiCoder | last post by:
I'm trying to simulate buttons using images. I tried many ways and I don't seem to get it to work as far as the button label is concerned. I tried manipulating "top" and "left" and now the margins and I'm getting bizarre results. This is not the actual code. I did what I had to do to make it independent from the website I'm working on and to "reduce" the problem to the bare minimum factors. <style type="text/css"> div.btn { width: 80px;...
5
13381
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL http://mghospedagem.com/images/controlpanel.jpg instead of http://mghospedagem.comhttp://mghospedagem.com/images/controlpanel.jpg As u see, there's the website URL before the image URL.
0
9647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9492
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10360
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10163
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8988
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7510
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6744
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5532
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.