facebook

problem calling javascript function from a jsp file

  1. MyEclipse Archived
  2.  > 
  3. Bugs
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #249003 Reply

    sabriz
    Member

    Hi,

    I am using Eclipse 3.1 and Myeclipse 4.1.1G version. I created a javascript file name date.js in a folder named javascript under webRoot folder. In this javascript file I had written a method to simply raise a alert window. I have a jsp file in the folder named jsp under webRoot folder. I have a button in that jsp and when I click this button the alert method in the javascript file should be called. But when I click on the button I can see a error message like “Obejct expected”. Here is my jsp coding.

    just.jsp

    <html>
    <head>
    <title>My JSP ‘just.jsp’ starting page</title>
    <script language=”JavaScript” src=”/javascript/date.js”></script>
    </head>

    <body>
    This is my JSP page. <br>
    <input type=”button” value=”run” onclick=”javascript:messagebox();”/>
    </body>
    </html>

    Here is my javascript coding…

    date.js

    function messagebox()
    {
    alert(“This is an alert message from js file”);
    }

    #249028 Reply

    Riyad Kalla
    Member

    You most likely want your src path for the javascript file to be relative, get rid of the preceeding /

    #255721 Reply

    anmardo1
    Member

    Hi, I’m having the same problem.

    And I am also sure it has nothing to do with “/” or path stuff, I worked months ago in a project and had this trouble, changed later to another different project (with different source code) and it’s the same again. Other guys work perfectly with the same files in their computers, and the only difference (or at least the most significative one) is that they don’t use MyEclipse (but I do).

    Could it be some possible compilation bug or something like this? 😕

    Thanks

    #255735 Reply

    Riyad Kalla
    Member

    anmardo,
    Post some more information for us. For one, start off posting your configuration/installation summary from the MyEclipse > About MyEclipse menu. Then tell us exactly what is happening and then give us some code snippets.

    #255820 Reply

    anmardo1
    Member

    Yes sorry, I should have posted more information 😛

    Here’s my MyEclipse conf:


    *** Date: Mon Jul 31 08:53:56 CEST 2006

    *** System properties:
    OS=WindowsXP
    OS version=5.1
    Java version=1.5.0_01

    *** MyEclipse details:
    MyEclipse Enterprise Workbench

    Version: 4.1.1 GA
    Build id: 20060228-4.1.1-GA

    *** Eclipse details:
    Eclipse SDK

    Version: 3.1.2
    Build id: M20060118-1600

    Eclipse Project SDK

    Version: 3.1.2
    Build id: M20060118-1600

    Eclipse Platform

    Version: 3.1.2
    Build id: M20060118-1600

    Eclipse Java Development Tools

    Version: 3.1.2
    Build id: M20060118-1600

    Eclipse Graphical Editing Framework

    Version: 3.1
    Build id: 200509301327

    Eclipse RCP

    Version: 3.1.2
    Build id: M20060118-1600

    Eclipse Plug-in Development Environment

    Version: 3.1.2
    Build id: M20060118-1600

    Eclipse startup command=-os
    win32
    -ws
    win32
    -arch
    x86
    -launcher
    D:\proyectos\eclipse\eclipse.exe
    -name
    Eclipse
    -showsplash
    600
    -exitdata
    f30_60
    -vm
    C:\WINDOWS\system32\javaw.exe

    The problem I have, with more detail, is the following one:

    I have a webproject which uses both Jsp and Java files. When I need to use some Javascript method, I usually save it into a js file, which I include or import into the *.jsp file and use it.

    Generally this works fine, but some few times I cannot “see” the Javascript method I need from the js. And the file is correctly imported or added or included, the only solution I’ve found is to copy the method into the local jsp file. Seems to be like a path error, but after lots of testing I am almost sure there’s nothing to do with it.

    Currently I’m working in a project in which I cannot simply copy the method into my Jsp code, and I don’t know what to do.

    I know it’s a weird trouble, so I only ask if there was a known compilation problem or something similar, because I have had this kind of strange behaviour with jsp files since I started using MyEclipse.

    However, I’m trying to use another Eclipse installations without MyEclipse. I will post everything I find here.

    Thank you very much 🙂

    #255821 Reply

    anmardo1
    Member

    Well,

    I have just installed Eclipse 3.1.1 without MyEclipse and now it works perfectly with the same source code.

    Maybe is a bug a little hard to find , but I’ve lost almost two days, if you find something with the data I’ve post before, I’ll try to check with this new ide.

    Thank you

    #255827 Reply

    Riyad Kalla
    Member

    I think I have completely misunderstood your original problem if you are saying this is now “working without MyEclipse”. Base Eclipse provides no web editing functionalty, was this entire bug report a run-time problem wth your application after it was deployed to your app server? I assumed it was a problem with the source code editor or designer.

Viewing 7 posts - 1 through 7 (of 7 total)
Reply To: problem calling javascript function from a jsp file

You must be logged in to post in the forum log in