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!
*/