calling a servlet from javascript
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Juanjo_Alonso
Posted On:   Wednesday, June 20, 2007 07:21 PM

I'm using a javascript widget: jscalendar 1.0 and I've tried my question in that site, but no response. The problem is that I try to call a servlet from a javascript code and everything works fine, except I get a page not found 404 exception in log files. It doesn't produce any problem to the application but I want to know how can I avoid it. Thanks in advance !! Juanjo The function used to make the request is dateChanged (in a jsp page): function dateChanged(calendar) { if (calendar.dateClicked) { // OK, a date was clicked, redirect to /yyyy/mm/dd/index.php var y = calendar.date.getFullYear(); var m = calendar.date.getMonth(); // inte   More>>

I'm using a javascript widget: jscalendar 1.0 and I've tried my question in that site, but no response.



The problem is that I try to call a servlet from a javascript code and everything works fine, except I get a page not found 404 exception in log files. It doesn't produce any problem to the application but I want to know how can I avoid it.



Thanks in advance !!
Juanjo



The function used to make the request is dateChanged (in a jsp page):



function dateChanged(calendar) {
if (calendar.dateClicked) {
// OK, a date was clicked, redirect to /yyyy/mm/dd/index.php
var y = calendar.date.getFullYear();
var m = calendar.date.getMonth(); // integer, 0..11
var d = calendar.date.getDate(); // integer, 1..31
// redirect...
if (dateIsSpecial(y, m, d))


window.location=" <%=response.encodeURL("myservlet")%>?m=3&v="+ d +"-"+ (m+1) +"-"+ y +"&a=0";


}



And the Stack trace:



2007-06-20 01:16:08 org.apache.catalina.core.StandardHostValve@8d2280: Exception Processing ErrorPage[errorCode=404, location=/noEncontrada.htm]
ClientAbortException: java.net.SocketException: Software caused connection abort: socket write error
at org.apache.coyote.tomcat5.OutputBuffer.doFlush(OutputBuffer.java:331)
at org.apache.coyote.tomcat5.OutputBuffer.flush(OutputBuffer.java:297)
at org.apache.coyote.tomcat5.CoyoteResponse.flushBuffer(CoyoteResponse.java:537)
at org.apache.coyote.tomcat5.CoyoteResponseFacade.flushBuffer(CoyoteResponseFacade.java:238)
at org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:303)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:147)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)

   <<Less

Re: calling a servlet from javascript

Posted By:   Michael_Lowden  
Posted On:   Thursday, June 21, 2007 08:21 PM

try updating:

window.location="<%=response.encodeURL("myservlet")%>?m=3&v="+ d +"-"+ (m+1) +"-"+ y +"&a=0";



--- to ---



window.location='"<%=response.encodeURL("myservlet")%>?m=3&v="+ d +"-"+ (m+1) +"-"+ y +"&a=0"';



--- or ---



<%= "window.location='" + response.encodeURL("myservlet") + "?m=3&v="+ d +"-"+ (m+1) +"-"+ y +"&a=0';"%>



weird i know. but give it a go.
About | Sitemap | Contact