java - Response been writen twice in custom servlet forwarding -
i need forward servlet been dynamically loaded jar custom class loader main servlet using external configuration file. servlet not mapped in web.xml. have been able load servlet , construct new instance using reflection , casting:
object o = loadedclass.newinstance() ; httpservlet loadedservlet = (httpservlet) o ;
i have initialized servlet as:
loadedservlet.init(getservletconfig()) ;
and implemented every do... method in main servlet as:
loadedservlet.service(request, response) ;
everything works expected exception of response getting output twice:
hello, world!hello, world!
is not issue of loaded servlet:
protected void doget(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { printwriter printwriter = response.getwriter() ; printwriter.write("hello, world!") ; } protected void dopost(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { doget(request, response) ; }
sorry if not enough specific. hint should at?
nevermind, found solution myself. call of response.reset() after calling servlet.service() needed.
loadedservlet.service(request, response) ; response.reset() ;
Comments
Post a Comment