• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

calling pop-up JavaScript calendar from JSP page

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm new to Java and to JavaRanch, and am creating a JSP administration page for a website. I am using the jscalendar-1.0 DHTML pop up calendar on this page.

When my page didn't have any JSP code on it, and just HTML, I saved the file as a .html file, and the pop up calendar worked perfectly. But as soon as I saved the same file with .jsp extension, it stopped working.

When I open the JSP page in my IE browser, I get two warnings. One that says "Expected Identifier", and one - "Calendar is undefined".

Here is how I called the files for the calendar on my JSP admin page:



Is something wrong with this? Do the pages need to be called differently from JSP pages?

I'd appreciate any advice or pointers,

Thanks!
 
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do a View Source of the JSP page after it has been delivered to the browser. How does it differ from the HTML version that worked?
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did the URL of the page change in any way other than changing html to jsp?

My first guess would be that the relative javascript files are not being loaded - which says to me either
- the jsp and the html file are in different folders
- you are accessing a servlet and forwarding to the jsp. In which case it will look for resources relative to the servlet URL.

 
Samantha Simon
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Thanks so much for trying to help me out!

The view source doesn't show any difference in the URLs. It shows some JSP code that the .html file doesn't show, but the files called look the same...

The URL of the .jsp page is no different than the URL of the .html page. Except for the extension, of course.

The JS files being called, are in a separate folder within the same folder as the .jsp and .html files are located.

Stefan, what do you mean by this sentence - "- you are accessing a servlet and forwarding to the jsp. In which case it will look for resources relative to the servlet URL."? I'm really new to programming, so I need extra simplified wording and explanations.

Thank you so much! If anyone has any ideas of how I'd solve this problem, please let me know...
 
Samantha Simon
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!

I'm not sure what the problem was. Probably something to do with how my files were set up in my directory. But switching from using static html tags to call the JS pages, to including the pages with JSP tags, solved the problem.

Here's what I swapped the html calls for. (Just in case someone else has my problem, too, one day):



And it worked!

Thanks for your suggestions and help,

Samantha
 
Bear Bibeault
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
While it may be working, it is not a good solution for others to emulate as it will prevent the JS files from being properly cached. The correct solution is to use the correct URLs with <script> tags.
 
Samantha Simon
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is my file structure. Maybe someone can help me get the right url... (And anyways, why would the URL be different than when I wrote them on the HTML pages?)

Folder1\jscalendar-1.0\(and here the files called from the JSP page)
Folder1\JSP file

Are my URLs correct for this structure?

Thanks so much for the input. I really appreciate it.

Samantha
 
Bear Bibeault
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using include is wrong, you should be using <script. tags with proper URLs that start with the context path.

E.g. assuming Folder1 (not a great choice of name) is in the app's root folder:



 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic