Including JavaScript into a JSP Page

Hi,
How do i include a piece of JavaScript <SCRIPT> stuff into a JSP Page?
Right now i have an HTML Page that includes some <SCRIPT> code. Now many other HTML files use this piece of <SCRIPT> stuff. How do i remove it , put it in one place(I mean where to put it and what would that file be called) and in a JSP page call this <SCRIPT> code?
Please help . i'm pretty new to JSP and JavaScript.
Thanks in Advance.
Phani
/**** CODE
<SCRIPT language=javascript>
<!--
     if ((document.images) && ("Netscape" != navigator.appName) && (navigator.appVersion.indexOf('Mac') == -1))
     document.write("<LINK REL=\"stylesheet\" TYPE=\"text/css\" HREF=\"http://www.telia.se/tews/css/1.css\">");
     else if ((document.images) && ("Netscape" != navigator.appName) && (navigator.appVersion.indexOf('Mac') > 1))
     document.write("<LINK REL=\"stylesheet\" TYPE=\"text/css\" HREF=\"http://www.telia.se/tews/css/5.css\">");
     else if (("Netscape" == navigator.appName) && (parseInt(navigator.appVersion) == 4) && (navigator.appVersion.indexOf('Mac') == -1))
     document.write("<LINK REL=\"stylesheet\" TYPE=\"text/css\" HREF=\"http://www.telia.se/tews/css/2.css\">");
     else if (("Netscape" == navigator.appName) && (parseInt(navigator.appVersion) == 4) && (navigator.appVersion.indexOf('Mac') > 1))
     document.write("<LINK REL=\"stylesheet\" TYPE=\"text/css\" HREF=\"http://www.telia.se/tews/css/3.css\">");
     else if (("Netscape" != navigator.appName) && ("Microsoft Internet Explorer" != navigator.appName))
     document.write("<LINK REL=\"stylesheet\" TYPE=\"text/css\" HREF=\"http://www.telia.se/tews/css/6.css\">");
// -->
</SCRIPT>

Ok, first let us make clear the demarcation between java and javascript.
Java runs on the server, and produces an HTML page which is sent to the client.
That HTML page may contain javascript code on it to run on the client side.
As the page is loaded, javascript may be compiled/run on the client.
So you have some javascript code which you want to include on every page as template text?
I would do this in JSP by using the include directive to add that bit of template text to every single JSP page.
ie
header.jspf
<SCRIPT language=javascript>
<!--
if ((document.images) && ("Netscape" != navigator.appName) && (navigator.appVersion.indexOf('Mac') == -1))
document.write("<LINK REL=\"stylesheet\" TYPE=\"text/css\" HREF=\"http://www.telia.se/tews/css/1.css\">");
else if ((document.images) && ("Netscape" != navigator.appName) && (navigator.appVersion.indexOf('Mac') > 1))
document.write("<LINK REL=\"stylesheet\" TYPE=\"text/css\" HREF=\"http://www.telia.se/tews/css/5.css\">");
else if (("Netscape" == navigator.appName) && (parseInt(navigator.appVersion) == 4) && (navigator.appVersion.indexOf('Mac') == -1))
document.write("<LINK REL=\"stylesheet\" TYPE=\"text/css\" HREF=\"http://www.telia.se/tews/css/2.css\">");
else if (("Netscape" == navigator.appName) && (parseInt(navigator.appVersion) == 4) && (navigator.appVersion.indexOf('Mac') > 1))
document.write("<LINK REL=\"stylesheet\" TYPE=\"text/css\" HREF=\"http://www.telia.se/tews/css/3.css\">");
else if (("Netscape" != navigator.appName) && ("Microsoft Internet Explorer" != navigator.appName))
document.write("<LINK REL=\"stylesheet\" TYPE=\"text/css\" HREF=\"http://www.telia.se/tews/css/6.css\">");
// -->
</SCRIPT>
<noscript>
  // stuff here for when the browser does not support javascript
</noscript>And then in every jsp page
<%@ page include="header.jspf" %>
// rest of the JSP pageThe file "header.jspf" will be included with every jsp page served, and you only need to update that page in one place.
If you have a JSP2.0 container you can define a jsp prelude which will be the same as having the <%@ page include="header.jspf" %> on every page.
You do this in the web.xml file:
Something like this:
  <jsp-property-group>
     <url-pattern>*.jsp</url-pattern>
     <include-prelude>/WEB-INF/jspf/prelude1.jspf</include-prelude>
  </jsp-property-group>The specified file will be loaded into every JSP page without the JSP page having to define the import itself.
Hope this helps,
evnafets

Similar Messages

  • Adding custom javascripts into my jsp pages

    Hi all,
    it will seems to be a newby question, i'm sorry i begin using jhs since two weeks
    the question is how can i Allow an onBlur property on VO Attributes; this property includes a piece of JavaScript to be executed on leaving the item to be generated in my jsp pages to prevent doing this in post-generation, by the way i would like to know who is the class responsible for the generation of form.js .
    thanks a lot
    best regards.
    Edited by: user1718070 on 3 févr. 2009 06:41

    Hi EvertJan, thanks for the reply.
    I need an advice:
    i've added an onblur event to jhsgenerator ADF BC property and i write as an example this.value=null
    i created a template in jspinput.xsl(JAGLauncher.jar) like this:
    <xsl:template name="onBlur">
    <xsl:param name="onBlur" />
    <xsl:if test="$onBlur !=''" >
    <xsl:attribute name="onblur">
    <xsl:value-of select="$onBlur" />
    </xsl:attribute>
    </xsl:if>
    </xsl:template>
    and i try to generate a html:text by modifing inputtextsec template like this:
    <xsl:template name="textInputSec">
    <xsl:param name="name"/>
    <xsl:param name="property"/>
    <xsl:param name="withIndex"/>
    <xsl:param name="size"/>
    <xsl:param name="maximumLength"/>
    <xsl:param name="updateable"/>
    <xsl:param name="displayType"/>
         <xsl:param name="onBlur" />
    <html:text name="{$name}" property="{$property}" size="{$size}" maxlength="{$maximumLength}" onblur="{$onBlur}">
    <xsl:call-template name="onBlur" >
    <xsl:with-param name="onBlur" select="$onBlur"/>
    </xsl:call-template>
              <xsl:if test="$withIndex = 'true'">
    <xsl:attribute name="indexed">
    <xsl:value-of select="'true'"/>
    </xsl:attribute>
    </xsl:if>
    <xsl:call-template name="disabledAttribute">
    <xsl:with-param name="updateable" select="$updateable"/>
    </xsl:call-template>
    </html:text>
         </xsl:template>
    also added this to CreateFormElement template in jsplibrary.xsl:
    <xsl:with-param name="onBlur" >
    <xsl:call-template name="getCustomProperty">
    <xsl:with-param name="entityAttribute" select="$entityAttribute"/>
    <xsl:with-param name="propertyName" select="'ON_BLUR'"/>
    </xsl:call-template>
    </xsl:with-param>
    but the result inemployees.jsp is not what i expected:
    <td class="prompt" nowrap="nowrap">FirstName</td>
    <td nowrap="nowrap">
    <html:text name="EmployeesBean" property="EmployeesFirstName" size="20" maxlength="30" onblur="" />
    </td>
    like yousee this.value=null is missing in onblur=""
    i hope you can help me
    Best regards

  • How include a Servlet into a JSP page?

    Hi!!
    I need make a combobox with a servlet and place its result into a jsp page.
    The servlet is in a package, but when i do: <jsp:include file="sic.view.servlet.ComboServlet" />
    tell me that "file attribute isn�t a valid attribute name"
    whow can i do to make the combobox whit the servlet and include this into the jsp page??
    Thanks!!
    PD: Sorry my pour English...

    Servlets should be mapped to a URL, then you access the servlet via that URL.
    The servlet mapping is done in the web.xml (in WEB-INF/ directory of your web application)
      <servlet>
        <servlet-name>
          Combo_S
        </servlet-name>
        <servlet-class>
          sic.view.servlet.ComboServlet
        </servlet-class>
      </servlet>
      <servlet-mapping>
        <servlet-name>
          Combo_S
        </servlet-name>
        <url-pattern>
          /combo
        </url-pattern>
      </servlet-mapping>Then you would use:
    <jsp:include file="combo" />
    to include it.
    Make sure the class file gets put in the right package under WEB-INF/classes/

  • Importing visual jsf page into another jsp page

    Hi
    I am developing a web application using jsp and struts. I want to embed a visual jsf page that Ive created into another jsp page (which is a normal jsp page, not a jsf one.)
    Ive tried quite a few things but nothing seems to work..
    <jsp:include page="Page2.jsp">
    Ive surrounded the code in the f:subview tags. still doesnt work.
    Ive tried using <jsp:useBean id="Page2" scope="page" class="visualwebapplication.Page2" > .. It does not give me an error, but does not embed the page as well. Do I need to some other code after this to use the above bean to display the page.
    Any help would be greatly appreciated.
    Regards
    Sparsh Agarwal

    Hi
    This is the error message that is generated in the tomcat log once i try to load the homePage.do
    Jul 31, 2008 2:27:47 PM org.apache.catalina.core.ApplicationContext log
    SEVERE: Cannot forward after response has been committed
    java.lang.IllegalStateException: Cannot forward after response has been committed
            at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:302)
            at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:292)
            at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:408)
            at com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:442)
            at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:115)
            at com.sun.rave.web.ui.appbase.faces.ViewHandlerImpl.renderView(ViewHandlerImpl.java:320)
            at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
            at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
            at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
            at com.sun.faces.extensions.avatar.lifecycle.PartialTraversalLifecycle.render(PartialTraversalLifecycle.java:106)
            at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
            at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654)
            at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:557)
            at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:481)
            at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:968)
            at org.apache.jsp.view.main_005fright_jsp._jspService(main_005fright_jsp.java:54)
            at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
            at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
            at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
            at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
            at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654)
            at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:557)
            at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:481)
            at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:968)
            at org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:609)
            at org.apache.struts.tiles.TilesUtilImpl.doInclude(TilesUtilImpl.java:99)
            at org.apache.struts.tiles.TilesUtil.doInclude(TilesUtil.java:135)
            at org.apache.struts.taglib.tiles.InsertTag.doInclude(InsertTag.java:760)
            at org.apache.struts.taglib.tiles.InsertTag$InsertHandler.doEndTag(InsertTag.java:892)
            at org.apache.struts.taglib.tiles.InsertTag.doEndTag(InsertTag.java:462)
            at org.apache.jsp.view.templates.layoutBase_jsp._jspx_meth_tiles_005finsert_005f5(layoutBase_jsp.java:255)
            at org.apache.jsp.view.templates.layoutBase_jsp._jspService(layoutBase_jsp.java:120)
            at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
            at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
            at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
            at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
            at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654)
            at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:445)
            at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:379)
            at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:292)
            at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1085)
            at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:263)
            at org.apache.struts.tiles.TilesRequestProcessor.processTilesDefinition(TilesRequestProcessor.java:239)
            at org.apache.struts.tiles.TilesRequestProcessor.internalModuleRelativeForward(TilesRequestProcessor.java:341)
            at org.apache.struts.action.RequestProcessor.processForward(RequestProcessor.java:572)
            at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:221)
            at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
            at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
            at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
            at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
            at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
            at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
            at java.lang.Thread.run(Thread.java:619)
    Jul 31, 2008 2:27:47 PM org.apache.catalina.core.ApplicationDispatcher invoke
    SEVERE: Servlet.service() for servlet Faces Servlet threw exception
    java.lang.IllegalStateException: Cannot forward after response has been committed
            at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:302)
            at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:292)
            at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:408)
            at com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:442)
            at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:115)
            at com.sun.rave.web.ui.appbase.faces.ViewHandlerImpl.renderView(ViewHandlerImpl.java:320)
            at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
            at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
            at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
            at com.sun.faces.extensions.avatar.lifecycle.PartialTraversalLifecycle.render(PartialTraversalLifecycle.java:106)
            at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
            at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654)
            at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:557)
            at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:481)
            at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:968)
            at org.apache.jsp.view.main_005fright_jsp._jspService(main_005fright_jsp.java:54)
            at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
            at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
            at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
            at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
            at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654)
            at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:557)
            at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:481)
            at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:968)
            at org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:609)
            at org.apache.struts.tiles.TilesUtilImpl.doInclude(TilesUtilImpl.java:99)
            at org.apache.struts.tiles.TilesUtil.doInclude(TilesUtil.java:135)
            at org.apache.struts.taglib.tiles.InsertTag.doInclude(InsertTag.java:760)
            at org.apache.struts.taglib.tiles.InsertTag$InsertHandler.doEndTag(InsertTag.java:892)
            at org.apache.struts.taglib.tiles.InsertTag.doEndTag(InsertTag.java:462)
            at org.apache.jsp.view.templates.layoutBase_jsp._jspx_meth_tiles_005finsert_005f5(layoutBase_jsp.java:255)
            at org.apache.jsp.view.templates.layoutBase_jsp._jspService(layoutBase_jsp.java:120)
            at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
            at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
            at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
            at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
            at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654)
            at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:445)
            at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:379)
            at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:292)
            at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1085)
            at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:263)
            at org.apache.struts.tiles.TilesRequestProcessor.processTilesDefinition(TilesRequestProcessor.java:239)
            at org.apache.struts.tiles.TilesRequestProcessor.internalModuleRelativeForward(TilesRequestProcessor.java:341)
            at org.apache.struts.action.RequestProcessor.processForward(RequestProcessor.java:572)
            at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:221)
            at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
            at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
            at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
            at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
            at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
            at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
            at java.lang.Thread.run(Thread.java:619)
    Jul 31, 2008 2:27:47 PM org.apache.catalina.core.ApplicationDispatcher invoke
    SEVERE: Servlet.service() for servlet jsp threw exception
    java.lang.IllegalStateException: Cannot forward after response has been committed
            at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:302)
            at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:292)
            at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:408)
            at com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:442)
            at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:115)
            at com.sun.rave.web.ui.appbase.faces.ViewHandlerImpl.renderView(ViewHandlerImpl.java:320)
            at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
            at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
            at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
            at com.sun.faces.extensions.avatar.lifecycle.PartialTraversalLifecycle.render(PartialTraversalLifecycle.java:106)
            at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
            at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654)
            at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:557)
            at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:481)
            at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:968)
            at org.apache.jsp.view.main_005fright_jsp._jspService(main_005fright_jsp.java:54)
            at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
            at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
            at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
            at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
            at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654)
            at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:557)
            at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:481)
            at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:968)
            at org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:609)
            at org.apache.struts.tiles.TilesUtilImpl.doInclude(TilesUtilImpl.java:99)
            at org.apache.struts.tiles.TilesUtil.doInclude(TilesUtil.java:135)
            at org.apache.struts.taglib.tiles.InsertTag.doInclude(InsertTag.java:760)
            at org.apache.struts.taglib.tiles.InsertTag$InsertHandler.doEndTag(InsertTag.java:892)
            at org.apache.struts.taglib.tiles.InsertTag.doEndTag(InsertTag.java:462)
            at org.apache.jsp.view.templates.layoutBase_jsp._jspx_meth_tiles_005finsert_005f5(layoutBase_jsp.java:255)
            at org.apache.jsp.view.templates.layoutBase_jsp._jspService(layoutBase_jsp.java:120)
            at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
            at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
            at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
            at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
            at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654)
            at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:445)
            at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:379)
            at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:292)
            at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1085)
            at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:263)
            at org.apache.struts.tiles.TilesRequestProcessor.processTilesDefinition(TilesRequestProcessor.java:239)
            at org.apache.struts.tiles.TilesRequestProcessor.internalModuleRelativeForward(TilesRequestProcessor.java:341)
            at org.apache.struts.action.RequestProcessor.processForward(RequestProcessor.java:572)
            at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:221)
            at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
            at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
            at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
            at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
            at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
            at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
            at java.lang.Thread.run(Thread.java:619)
    Jul 31, 2008 2:27:47 PM org.apache.catalina.core.ApplicationDispatcher invoke
    SEVERE: Servlet.service() for servlet jsp threw exception
    javax.servlet.jsp.JspException: ServletException in '/view/main_right.jsp': Cannot forward after response has been committed
            at org.apache.struts.taglib.tiles.InsertTag$InsertHandler.doEndTag(InsertTag.java:923)
            at org.apache.struts.taglib.tiles.InsertTag.doEndTag(InsertTag.java:462)
            at org.apache.jsp.view.templates.layoutBase_jsp._jspx_meth_tiles_005finsert_005f5(layoutBase_jsp.java:255)
            at org.apache.jsp.view.templates.layoutBase_jsp._jspService(layoutBase_jsp.java:120)
            at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
            at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
            at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
            at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
            at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654)
            at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:445)
            at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:379)
            at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:292)
            at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1085)
            at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:263)
            at org.apache.struts.tiles.TilesRequestProcessor.processTilesDefinition(TilesRequestProcessor.java:239)
            at org.apache.struts.tiles.TilesRequestProcessor.internalModuleRelativeForward(TilesRequestProcessor.java:341)
            at org.apache.struts.action.RequestProcessor.processForward(RequestProcessor.java:572)
            at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:221)
            at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
            at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
            at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
            at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
            at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
            at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
            at java.lang.Thread.run(Thread.java:619)
    Jul 31, 2008 2:27:47 PM org.apache.catalina.core.StandardWrapperValve invoke
    SEVERE: Servlet.service() for servlet action threw exception
    javax.servlet.jsp.JspException: ServletException in '/view/main_right.jsp': Cannot forward after response has been committed
            at org.apache.struts.taglib.tiles.InsertTag$InsertHandler.doEndTag(InsertTag.java:923)
            at org.apache.struts.taglib.tiles.InsertTag.doEndTag(InsertTag.java:462)
            at org.apache.jsp.view.templates.layoutBase_jsp._jspx_meth_tiles_005finsert_005f5(layoutBase_jsp.java:255)
            at org.apache.jsp.view.templates.layoutBase_jsp._jspService(layoutBase_jsp.java:120)
            at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
            at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
            at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
            at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
            at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654)
            at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:445)
            at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:379)
            at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:292)
            at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1085)
            at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:263)
            at org.apache.struts.tiles.TilesRequestProcessor.processTilesDefinition(TilesRequestProcessor.java:239)
            at org.apache.struts.tiles.TilesRequestProcessor.internalModuleRelativeForward(TilesRequestProcessor.java:341)
            at org.apache.struts.action.RequestProcessor.processForward(RequestProcessor.java:572)
            at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:221)
            at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
            at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
            at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
            at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
            at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
            at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
            at java.lang.Thread.run(Thread.java:619)

  • How can I access xml document from javascript whithin a JSP page

    how can I access xml document from javascript whithin a JSP page?
    I have a JSP that receives an XML document from a JavaBean, so I can access it within the entire JSP, but I need to access it from the javascript inside the JSP... and I have no idea how i can do this.
    Thanks in advance!

    The solution would only work on MS IE browsers, as other browsers do not support an XML DOM.
    It can be done, but you would be stuck with using the Microsoft broswer. If that is acceptable, I have some example code, and a book recommendation.

  • What's up when you drag and drop a table into a jsp page?

    Hi All,
    I was wondering what's happen in dragging and drop a table into a jsp page. This question because untill yesterday i had an application up and running, with a table displaying a number of rows of the database, and an action associated with an update into a database.
    The action is managed trough JNDI, defined from Preference-Embedded.......
    It was working.
    Then the machine hosting the db changed IP addres. I went into Webcenter Administration console, I've changed the connection string into the jdbc parameters, by updating the new IP address... but it's not working anymore! The log comes out with a big error, but basically it can't connect at the db!
    So, I think there is somewhere some reference to the old db.....where???
    Thanks
    Claudio

    Yes Shay,
    I got this error:
    JBO-29000: Unexpected exception caught: oracle.jbo.JboException, msg=JBO-29000: Unexpected exception caught: oracle.jbo.JboException, msg=JBO-29000: Unexpected exception caught: oracle.jbo.DMLException, msg=JBO-26061: Error while opening JDBC connection.
    in few hours I'll be able to give you the full stack.
    Thanks
    Clauido
    Message was edited by:
    user637862
    Hi Shay,
    Thanks a lot..you were right.
    I've located the ba4j on the webcenter server...and I've noticed that it was with the old address.
    I think it's a bug, cause on the local machine (before to deploy) this file comes with the right address.
    So next time, before to redeploy a new application, I think I'm going to fiscally delete the folder from j2ee folder.
    Thanks again for the help!
    Claudio

  • How do I Display a string from a servlet into a JSP Page???? NEED HELP!!!!

    Hi guys,
    How do I Display a string from a servlet into a JSP Page...
    Ive tried so many bloody things!.....
    Simply.
    I get text from JSP. The servlet does what ever it does to the string.
    Now. Ive create sessions and bean things,.... how the hell do I display it in a text box... I can display on the screen.. but not in the text box.!!!
    please help!!!

    hmmm, I dont really like using JSP programming, u should be using JAVA..
    the way to do it is:
    Call and cast to the bean like this:
    <%@ page import="beans.*" %>
    <% //cast to bean get request create object
    userNameBean u= (userNameBean) request.getSession().getAttribute("userNameBean");
    then... all you do is call it like this:
    <input type="text" name="firstName" value="<%= u != null? u.getFirstName(): "" %>">
    this is the real programmers way,,,
    chet.~

  • How can we  use java variable in javascript code on JSP page?

    How can we use java variable in javascript code on JSP page?
    Pls help

    Think about it:
    JSP/Java is executed on the Server and produces HTML+JavaScript.
    Then that HTML+JavaScript is transfered to the client. The client now interpretes the HTML+JavaScript.
    Obviously there's no way to access a Java variable directly from JavaScript.
    What you can do, however, is write out some JavaScript that creates a JavaScript variable containing the value of your Java variable.

  • Include a Servlet into a JSP page

    Hi guys,
    When i try to include a Servlet into my JSP, the execution of the JSP stops...Somebody know why???

    Hi guys,
    When i try to include a Servlet into my JSP,the
    execution of the JSP stops...Somebody knowwhy???
    No, and do you know why ? Bcos including a
    servlet
    in
    a jsp doesnt stop the execution of the jsp. Sotell
    us that you tried to do, post some relevant
    code,
    for us to help you.
    ram.<%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@page buffer="500kb"%>
    <html>
    <head><title>JSP Page</title></head>
    <body>
    <jsp:include page="/showCryptValue"
    ptValue" flush="true" />
    asdfasdfasdfasdfasdf
    </body>
    </html>
    that's the source code....do you have any idea????
    Thak's a lottttFrom linxpda:
    1) setting the flush="false" parameter for thejsp:include tag?
    Here is the problem that I, and perhaps linxpda,
    think you have:
    You get an exception in the servlet.
    You have already written to and flushed the response,
    therefore you can not see the exception on your
    screen (seeing the exception on screen requires a
    send redirect to the error page, which can't happend
    when the response is already committed).
    The exception that is occuring MAY be alreay written
    in your logs, take a look.
    To see the problem on screen so as to be able to
    identify it, make sure your include tag DOES NOT
    flush the buffer. That means change
    <jsp:include page="/showCryptValue" flush="true" />
    to
    <jsp:include page="/showCryptValue" flush="false" />Hi!
    No even setting flush false or true it works...If somebody have done this before tell me how have you did....If you can post your code!
    []'s
    Falow

  • Need a fast answer... passing javascript variable to jsp page (how to use)

    This test application has 3 frames.
    I'm assigning a value "stuff" to a variable ("testfield1") in a javascript function ("getTest") that exists inside an html frame (testpage1.html)
    Then, I click on the "test submit" hypertext link to pass the value of "testfield1" to the JSP frame (testpage2.jsp) by invoking a function ("getData") in "testpage2".
    In function ("getData"), I am passing the variable "testfield1" as a parameter to the "getData" function in "testpage2".
    In "testpage2" - in the ("getData" function) I try to assign the value of the variable "testfield1" to another variable called "testfld1".
    Then, I try to extract the value of "testfld1" into a variable called "tstfld1" in a JSP scriptlet
    ....I.E. [ String tstfld1  = request.getParameter("testfld1");  ]
    But, the value is apparently not passed successfully, as tstfield1 appears to be "null".
    Can anyone explain what I'm doing incorrectly?
    The code for this test app is below...
    ********testpage0 - the parent frame*********
    <HTML>
    <HEAD>
    <TITLE>GlobalView Reports and Trending Menubar</TITLE>
    </HEAD>
    <FRAMESET FRAMEBORDER="0" ROWS="15%,85%">
    <FRAME SRC="testpage0.html" NAME="testhtmlparent">
    <FRAMESET FRAMEBORDER="0" COLS="23%,77%">
    <FRAME SRC="testpage1.html" NAME="testhtml">
    <FRAME SRC="testpage2.jsp" NAME="testjsp">
    </FRAMESET>
    </FRAMESET>
    </HTML>
    *******testpage1.html********
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <html>
         <head><title>testpage1</title>
         <link rel="stylesheet" type="text/css" href="./standard.css">
              <script LANGUAGE="JavaScript">
              parent.frames[2].location = "blank.html";
              function getTest(reportType)
                   testfield1 = "stuff";
                   alert("testpage1.html...testfield1=" + testfield1 + ", reportType=" + reportType);
                   parent.frames[2].location = "testpage2.jsp";
                   parent.frames[2].getData(testfield1);
                   return;
              </script>
         </head>
         <body bgcolor="#FFFFFF" text="#000000">
              <form name="reportRange">
                   <center>
                        <fieldset style="padding: 0.5em" name="customer_box">
                        <table cellpadding="0" cellspacing="0" border="0">
                             <tr class="drophead">
                                  <td valign="top" height="0" ><span class="drophead">
                                       test submit
                                  </td>
                             </tr>
                        </table>
                        </fieldset>
                   </center>
              </form>
         </body>
    </html>
    *******testpage2.jsp*********
    <%@ page language="java" import="java.io.*, java.util.*" errorPage="error.jsp" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <html>
         <head>
         <title>testpage2</title>
         <script language="JavaScript">
              function getData(testfield1)
                   alert("testpage2.jsp...testfield1=" + testfield1);
                   document.pageData.testfld1.value = testfield1;
                   document.pageData.submit();
         </script>
         </head>
         <body>
              <%
                   String error;
              %>
              <div id="HiddenForm">
                   <form name="pageData" method="post" action="testpage2.jsp" target="_self">
                   <input type="hidden" name="testfld1" value="0">
              </form>
              </div>
              <%
                   String tstfld1 = request.getParameter("testfld1");
              %>
              <P> testfld1 = <%= tstfld1 %> </P>
         </body>
    </html>

    parent.frames[2].getData(testfield1); is in testpage1.html
    so in the document.pageData.testfld1.value = testfield1; document = testpage1.html( not testpage2.html)
    modifying the getData to accept the document object, and refering this object to parent.frames[2].document may help you.
    good Luck ....

  • Trying to dynamic include HTML into a JSP

    All,
    I am trying to include an HMTL file into a JSP file. I wish to do this dymanically. So, the following is not an option:
    <%@ include file="relativeURL" %>
    So, I am forced to resort to such measures as the following:
    <jsp:include page="<%=myPath%>"/>
    However, I get the following error:
    java.lang.IllegalStateException: Response has already been committed
         at java.lang.Throwable.fillInStackTrace(Native Method)
         at java.lang.Throwable.fillInStackTrace(Compiled Code)....
    I tried it like this:
    <jsp:include page="<%=myPath%>" flush="true"/>
    I encoutered the same result. I have JSP 1.2 running Tomcat 3.1 with Apache 1.3.14, all on SunOS. Thanks in advance for any help.
    Nicholas

    One of the worst error messages you can get is the IllegalStateException. It simply means that an attempt has been made to forward or include but only a portion of the include was sent. In a situation like this the best way to handle the dynamic page content is to include it from a Servlet by sending the information you need through beans. Including the Servlet rather than the dynamic path would clear those errors right up. One thing to keep in consideration is that you can't just get the page and display it, you have to buffer it in so the state can be kept alive without timing out like it does with the dynamic include.
    Hope that helps. Been there, done that, I know how frustrating the error was.

  • Retrieving lists from other layer into a JSP page - Design Question

    Hi all,
    What should be a good design technique in order to allow a JSP page to present some list obtained from other layer of my application. I intend to leave only presentation logic in the JSP layer, while all data access will be in other layer.
    For example, I have a JSP page that will show the results of a SQL query originated from an entry form in other JSP page. Let's name them 'search.jsp' and 'result.jsp'
    I want that all JDBC access be done in some other layer.
    Question 1:
    What would be better for this task? A servlet or a bean? (A bean, I suppose?)
    Then this bean (?) would have to find some way to pass all the result set into this 'result.jsp'. I think it would be very poor design if I used some Data Object, because it would have to store all rows and pass them at once.
    I don't want, either, that the presentation (JSP) layer access directly the data access layer (JDBC, files...). This way, I don't want any JSP page accessing the Resultset object directly.
    Question 2:
    What do you think could be a good design technique?
    I thought of some intermediate layer that provided data objects and data access interfaces. I mean, as my data will come from different sources, like some database (JDBC), some Electronic Document Manager, I thought of having a common access interface, that would provide methods for accessing the resultsets. This could be even a java.util.Enumeration that has a hasMoreElements() method that could be implemented as the next() method from JDBC result sets and the nextElement() method that would actually bring the next row of data.
    This way the JSP layer would see only hasMoreElements() and nextElement() methods from the middle layer. On the other hand, the data layer would provide as many different implementations to this access interface (Enumeration?) as there were data sources (JDBC, Files, ...)
    Question 3:
    What do you think of this design?
    Question 4:
    Is there any flaw in my approach? Which?
    Question 5:
    Could you suggest other designs?
    I really thank you all, for any kind of answer. I actually use this design for development, however I've never seriously discussed it with someone... this is going to be of great value for me.
    Regards,
    Filipe Fedalto

    Well I saw you question and I'll tell you what I do.
    I have JSP's which post form data to servlets.
    The servlet then calls a factory to produce a ResultContainer (analagous to your lists) which is generated
    via JDBC, and/or request parameters etc...
    this provides a single point of reference and a "group" of containers (functions really) that can be produced and reused (same container different amount of data)
    I also have other static classes which can manipulate the data in the containers
    (such as add additional info to the items in the containers) before I forward the container (request attribute)
    to the JSP page
    Additionally I use Type safe constants for all my HTML form tag names (easier to change and ensure the same name is used everywhere when reading parameters) and again for item statuses
    and any other info I need to send along with the page (using Javascript to update the
    status to another type safe constant).
    I've found that using factories for ResultContainers is very worthwhile and allows you to implement additional servlets extremely quickly (mostly reusing containers that exist) and since the
    container is the same for all my JSPs (this may not be the case with you) I can implement JSP's
    very quickly as well (just change the view)
    btw I refrain from calling my ResultContainer a bean because it is not serializable
    I don't know if this will help but at least it gives me a forum to test my ideas
    Thanks

  • How to get the value retruned by java script function into my jsp page

    Hai all,
    I had a particular java script function which returns a date.
    function getDate() {
         var sDate;
    // This code executes when the user clicks on a day in the calendar.
    if ("TD" == event.srcElement.tagName)
    // Test whether day is valid.
    if ("" != event.srcElement.innerText)
    //alert(event.srcElement.innerText);
    sDate = document.all.year.value + "-" + document.all.month.value + "-" + event.srcElement.innerText;
    document.all.ret.value = sDate;
    var mahi=window.open("configurexml.jsp?xyz=document.all.ret.value")
    return sDate;}
    Now i want to display this particular date in my jsp page. can anyone tell me the correct approach or a sample code to diaplay this date in my jsp page.
    <%@ page language="java"
    import="javax.xml.parsers.*,java.io.*,org.w3c.dom.*"%><%@ page import="java.util.*" %>
    !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html> <head> <title>Configuring Xml File</title>
    <SCRIPT LANGUAGE="JavaScript" SRC="xyz.js"> </SCRIPT>
    body bgcolor="#d0d0d0" onClick= "return getDate()" >
    <form name="f1">
    <b>20 october 2006 </b>
    Here where i am printing the date i had to get the value from the js function. how to do that. plz help me....

    Are you talking about server-side java code (servlets/jsp) or client side (applet)? Given we are in the JSP forum I'll assume we're talking server side.
    If so, you are making a common but fundamental mistake. JavaScript executes on the client, not on the server. If you want client data on the server it has to get there somehow. The simplest way to do this in JSP land is via HTTP. So... have your JavaScript code call a JSP (or servlet) and pass the value you want as a URL parameter. Of course this will also change the browser location, so if you don't want this to happen use a frame or iframe to capture your HTTP request.
    For example:
    Javascript....
    function someFunction() {
    return 1;
    var value = someFunction();
    location.href="somejsp.jsp?value=" + value;

  • How to open a local file from javascript in a jsp-page

    Hi
    I have created an iview from a PAR file. In the par file I have a jsp-page with some javascript code. From the javascript coe I want to open a new window with an Excel file.
    I have tried window.open("c:
    test.xls", "test_window"), but it doesn't seem to work. I have created a small HTML page locally with the same command and there a new window opens with the Excel file.
    If I change the local file path with an URL it also works.
    Any idea how to open a local file ?
    Thanks
    /Jakob

    Jacob,
    I'm not 100% (but 99,9%) and it has to do with security ristrictions of the browser not allowing to have local workstation interation from the web. This is ofcourse very dangerous if the browser would allow it... So therfore it is blocked. What if somone would point to a file/executable that formats your drive so for that reason it is not allowed to have web interaction with a local file. Only with Java Applets this is possible but still with many limitations, and what I remember Google Gears and Adobe Air do have some limited web 2 local file interaction... So best and most simple solution you are left with is pointing to a url instead of a file on a c:\ drive.
    PS The reason why it works when you start the html from your local PC has todo with the fact that the browser detects that the html is not running in the web at that moment therefor allowing the access.
    Cheers,
    Benjamin Houttuin

  • Include xml file in jsp page

    hi,
    i just would like to include an xml file and his xsl file in a jsp page.
    i know we can do it in asp like that :
    <%
    //load the xml file
    var source = Server.CreateObjetc("Microsoft.XMLDOM");
    source.load(Server.MapPath("toto.xml"));
    //load the associated xsl file
    var style = Server.CreateObject("Microsoft.XMLDOM");
    style.load(Server.MapPath("toto.xsl"));
    //transform the source document
    var result = source.transformNode(style);
    Response.Write(result);
    %>
    i want exactly do the same in jsp
    does anyone know how to do?

    where is the big deal? there are many posts answering this in the forum.
    here is a possibility:
    <%@page contentType="text/html;charset=utf-8"%>
    <%@page import="javax.xml.transform.*,javax.xml.transform.stream.*" %><%
    Templates myTemplates = TransformerFactory.newInstance().newTemplates(new StreamSource(new File("whatever.xsl")));
    Transformer transformer = myTemplates.newTransformer();
    StringWriter sw = new StringWriter();
    transformer.transform(new StreamSource(new File("whatever.xsl")), new StreamResult(sw));
    out.print(sw.toString());
    %>

Maybe you are looking for

  • Different Line Item needs to be displayed in ALV

    Hi All, We have a requirement where in we have to display separate line items corresponding to the separate header in ALv. we are using the FM REUSE_ALV_HIERSEQ_LIST_DISPLAY, but it is displaying all the line items in all different headers . For Eg:

  • Get Folder details(CV01N) based on material.

    Hi Friends, I have created a document(CV01N) and linked the material via program. I need to add the same material in root folder which is in Document browser tab. I'll get the corresponding material number range and add it. How to get the folder base

  • Components getting distorted when the JFrame application is minimized

    Hello, I have developed a GUI application using Net Beans, the JFrame has a panel which has a JButton, JTextField, image icon (using label) and few other label's, when i click the button the text fields, image icon, button relocate using setBounds fu

  • Two tables that provide detail information about data source?

    what are the tables that provide information about the datasource? How to prevent duplicate records in at the data target level?

  • Alerts: background job scheduling

    Hi i have defined alerts, and gave "no restriction " alert rule in runtime workbench. my doubt is whether can we define background jobs for the alerts. if so how it will be possible and how it will impact the performance of the XI server?? how can we