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:
--------------- - <%--
-
Document : UserSignOn
-
Created on : Mar 13, 2008, 4:07:08 PM
-
Author : ankittoshniwal
-
--%>
-
-
<%@page contentType="text/html" pageEncoding="UTF-8"%>
-
-
-
-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
-
"http://www.w3.org/TR/html4/loose.dtd">
-
-
<html>
-
<head>
-
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-
<title>User Sign On</title>
-
<script language="javascript">
-
var xmlHttp;
-
-
function createXmlHttpRequest()
-
{
-
try
-
{
-
xmlHttp = new XMLHttpRequest();
-
-
} catch (tryMicrosoft)
-
{
-
try {
-
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
-
}
-
catch (otherMicrosoft)
-
{
-
try
-
{
-
request = new ActiveXObject("Microsoft.XMLHTTP");
-
}catch (failed)
-
{
-
xmlHttp = false;
-
}
-
}
-
}
-
-
if (!xmlHttp)
-
alert("error initializing XMlHttpRequest");
-
}
-
function callServer()
-
{
-
-
createXmlHttpRequest();
-
// var nameValue = document.getElementById("n");
-
var userNameValue = document.getElementsByName("user").value;
-
-
var url = "/TestProject-war/data?tempUserName=" + escape(userNameValue);
-
-
xmlHttp.open("GET", url, true);
-
-
xmlHttp.onreadystatechange = confirmUpdate;
-
-
xmlHttp.send(null);
-
-
}
-
-
function confirmUpdate()
-
{
-
-
if (xmlHttp.readyState == 4)
-
{
-
if (xmlHttp.status == 200)
-
{
-
-
var message =
-
xmlHttp.responseXML
-
.getElementsByTagName("valid")[0]
-
.childNodes[0].nodeValue;
-
-
// Basically this is the point which is giving me errors
-
document.getElementById("results").innerHTML = message;
-
-
}
-
else
-
{
-
alert("Error loading page" + xmlHttp.status );
-
}
-
}
-
-
-
}
-
</script>
-
-
</head>
-
<body>
-
-
<p> We are trying to read</p>
-
<input type="text" onkeyup="callServer();"/>
-
<td width="31%" id=”results”> </td>
-
-
</body>
-
</html>
-
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: - /*
-
* To change this template, choose Tools | Templates
-
* and open the template in the editor.
-
*/
-
-
package org.web;
-
-
import java.io.*;
-
import java.net.*;
-
import java.math.*;
-
-
import java.util.List;
-
import java.util.ListIterator;
-
import javax.ejb.EJB;
-
import javax.servlet.*;
-
import javax.servlet.http.*;
-
import org.ejb.UserDetailsFacadeLocal;
-
import org.ejb.UserDetails;
-
-
/**
-
*
-
* @author ankittoshniwal
-
*/
-
public class data extends HttpServlet {
-
@EJB
-
private UserDetailsFacadeLocal userDetailsFacade;
-
-
String tempUsr;
-
String tempUsername;
-
String tempId;
-
/**
-
* Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
-
* @param request servlet request
-
* @param response servlet response
-
*/
-
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
-
throws ServletException, IOException {
-
response.setContentType("text/html;charset=UTF-8");
-
PrintWriter out = response.getWriter();
-
try {
-
// TODO output your page here
-
out.println("<html>");
-
out.println("<head>");
-
out.println("<title>Servlet data</title>");
-
out.println("</head>");
-
out.println("<body>");
-
out.println("<h1>Servlet data at " + request.getContextPath () + "</h1>");
-
UserDetails UserDetailsObj = new UserDetails();
-
out.println("</body>");
-
out.println("</html>");
-
-
} finally {
-
out.close();
-
}
-
}
-
-
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
-
/**
-
* Handles the HTTP <code>GET</code> method.
-
* @param request servlet request
-
* @param response servlet response
-
*/
-
protected void doGet(HttpServletRequest request, HttpServletResponse response)
-
throws ServletException, IOException {
-
-
PrintWriter out = response.getWriter();
-
UserDetails userObj = new UserDetails();
-
// String checkName = request.getParameter("name");
-
// String checkUserName = request.getParameter("user");
-
// String temp;
-
-
response.setContentType("application/xml");
-
response.setHeader("Cache-Control", "no-cache");
-
response.getWriter().write("<valid>true</valid>");
-
}
-
-
/**
-
* Handles the HTTP <code>POST</code> method.
-
* @param request servlet request
-
* @param response servlet response
-
*/
-
protected void doPost(HttpServletRequest request, HttpServletResponse response)
-
throws ServletException, IOException {
-
-
PrintWriter out = response.getWriter();
-
-
doGet(request, response);
-
// processRequest(request, response);
-
}
-
-
/**
-
* Returns a short description of the servlet.
-
*/
-
public String getServletInfo() {
-
return "Short description";
-
}
-
// </editor-fold>
-
}
----------------------------------------------------------------------
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.
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
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.
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
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.
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".
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
acoder 16,027
Recognized Expert Moderator MVP
Thank you for the correction acoder
Not necessarily a correction - more improvements/alternatives.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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';
|
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) {
|
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...
|
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;...
|
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.
| |
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...
|
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,...
|
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...
|
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...
|
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...
|
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...
| |
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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...
| |