Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2007

Tip: Looking for answers? Try searching our database.

Javascript and Struts, question

Thread view: 
simplengrichard@gmail.com - 03 Oct 2007 03:40 GMT
Hi!

We are currently developing an  web application using the Jakarta
Struts framework (1.3).  Since a lot of our forms involve date fields,
we used a javascript datepicker, a calendar displayed in a separate
window and the date picked is reflected on the textfield on the
original page.  The javascript is located in an external js file.
When we access the page directly, as in localhost:8080/website/pages/
page.jsp, there is no problem. The datepicker works correctly.
However, if the page is accessed through a forward action localhost:
8080/website/ForwardToAction.do, a javascript error occurs.  the
datepicker does not display in a new window.  I viewed the error
console of firefox and its says that it is not defined.  I do not know
what seems to be the problem.  I am not sure but I was thinking that
because the page is accessed through a forward action then the html
head of the jsp page (where the script declaration for the javascript
is located) is not read.  Thank you for your help.
Ed Webb - 03 Oct 2007 09:22 GMT
> Hi!
>
[quoted text clipped - 13 lines]
> head of the jsp page (where the script declaration for the javascript
> is located) is not read.  Thank you for your help.

I'm guessing that you have the line:

<script type="text/javascript" src="datepicker.js"/>

when the client requests the jsp page directly the browser is requesting:

localhost:8080/website/pages/datepicker.js

but when the client requests the action the browser is requesting:

localhost:8080/website/datepicker.js

because you have entered it as a relative url and the browser only knows
about the url it requested localhost:8080/website/ForwardToAction.do and
cannot possibly know that you redirected its request to a different file
in a different directory. One answer would be to make an absolute
reference to the javascript file in the jsp page. Maybe there are better
solutions.

Ed!
Luke Yan - 04 Oct 2007 01:28 GMT
another solution is to make your JSP and Action URL have the same URI.

for example, if your Action URL is "/website/pages/ForwardToAction.do"

~~~~~~~~~~~~~~~~
I believe problem you face to now there will be fixed.

ÔÚ Wed, 03 Oct 2007 08:22:11 GMT ʱ, Ed Webb <ed_j_webb@yahoo.com> дÁË:
--

>> Hi!
>>
[quoted text clipped - 34 lines]
>
>Ed!

--
MSN: gumpagain44#hotmail.com
/**
/* Java Is Not Platform-independent.It Is The Platform!
*/


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.