null pointer exception using <html:javascript>

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ajos
    Contributor
    • Aug 2007
    • 283

    null pointer exception using <html:javascript>

    hi all,
    im getting some problems in my javascript validations.... .
    my jsp code-->
    [HTML]
    8: <head>
    9: <title>Budget Master Administration</title>
    10: <meta name="GENERATOR " content="Micros oft FrontPage 3.0">
    11: <html:javascrip t src="bscript.js " method="everyth ing(this)" staticJavascrip t="false"/>
    12: <!-- <SCRIPT LANGUAGE="JavaS cript" SRC="bscript.js "></SCRIPT> -->
    13: <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    14: </head
    [/HTML]

    the exception that im getting is-->
    SEVERE: Servlet.service () for servlet jsp threw exception
    java.lang.NullP ointerException
    at org.apache.stru ts.taglib.html. JavascriptValid atorTag.doStart Tag(JavascriptV alidatorTag.jav a:316)
    at org.apache.jsp. pages.admin.add bdgt_jsp._jspx_ meth_html_005fj avascript_005f0 (addbdgt_jsp.ja va:157)
    at org.apache.jsp. pages.admin.add bdgt_jsp._jspx_ meth_html_005fh tml_005f0(addbd gt_jsp.java:120 )
    at org.apache.jsp. pages.admin.add bdgt_jsp._jspSe rvice(addbdgt_j sp.java:91)
    at org.apache.jasp er.runtime.Http JspBase.service (HttpJspBase.ja va:98)
    at javax.servlet.h ttp.HttpServlet .service(HttpSe rvlet.java:803)
    at org.apache.jasp er.servlet.JspS ervletWrapper.s ervice(JspServl etWrapper.java: 328)
    at org.apache.jasp er.servlet.JspS ervlet.serviceJ spFile(JspServl et.java:315)
    at org.apache.jasp er.servlet.JspS ervlet.service( JspServlet.java :265)
    at javax.servlet.h ttp.HttpServlet .service(HttpSe rvlet.java:803)
    at org.apache.cata lina.core.Appli cationFilterCha in.internalDoFi lter(Applicatio nFilterChain.ja va:269)
    at org.apache.cata lina.core.Appli cationFilterCha in.doFilter(App licationFilterC hain.java:188)
    at org.apache.cata lina.core.Stand ardWrapperValve .invoke(Standar dWrapperValve.j ava:210)
    at org.apache.cata lina.core.Stand ardContextValve .invoke(Standar dContextValve.j ava:174)
    at org.apache.cata lina.core.Stand ardHostValve.in voke(StandardHo stValve.java:12 7)
    at org.apache.cata lina.valves.Err orReportValve.i nvoke(ErrorRepo rtValve.java:11 7)
    at org.apache.cata lina.core.Stand ardEngineValve. invoke(Standard EngineValve.jav a:108)
    at org.apache.cata lina.connector. CoyoteAdapter.s ervice(CoyoteAd apter.java:151)
    at org.apache.coyo te.http11.Http1 1Processor.proc ess(Http11Proce ssor.java:870)
    at org.apache.coyo te.http11.Http1 1BaseProtocol$H ttp11Connection Handler.process Connection(Http 11BaseProtocol. java:665)
    at org.apache.tomc at.util.net.Poo lTcpEndpoint.pr ocessSocket(Poo lTcpEndpoint.ja va:528)
    at org.apache.tomc at.util.net.Lea derFollowerWork erThread.runIt( LeaderFollowerW orkerThread.jav a:81)
    at org.apache.tomc at.util.threads .ThreadPool$Con trolRunnable.ru n(ThreadPool.ja va:685)
    at java.lang.Threa d.run(Unknown Source)
    whats wrong with this ...plz throw some light on this...
    regards,
    ajos
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Can you not use normal HTML script tags?

    Comment

    • ajos
      Contributor
      • Aug 2007
      • 283

      #3
      Originally posted by acoder
      Can you not use normal HTML script tags?
      hi acoder sorry for the delayed reply,
      ive solved the first part of the problem,i.e i had to modify my javascript file coz
      my function in js was not returning a boolean value to stop the form from posting...
      my other problem here is..its working well with the <script> tag as u said...but its not working when i use this--->
      <html:javascrip t src="bscript.js "/>
      why so different tags behave differently in different situations?
      ragards,
      ajos

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        The proper way would be like:
        [HTML]<script type="text/javascript" src="jsfile.js" ></script>[/HTML] What does the JSP code turn into on the client-side?

        Comment

        • ajos
          Contributor
          • Aug 2007
          • 283

          #5
          Originally posted by acoder
          The proper way would be like:
          [HTML]<script type="text/javascript" src="jsfile.js" ></script>[/HTML] What does the JSP code turn into on the client-side?
          hi acoder,
          im using this code
          [HTML]<script type="text/javascript" src="jsfile.js" ></script>[/HTML] What
          but unable to use
          [HTML]<html:javascrip t src="jsfile.js" >[/HTML]
          simply an error/exception screen is shown.
          regards,
          ajos

          Comment

          • ajos
            Contributor
            • Aug 2007
            • 283

            #6
            my question is why the browser is unable to identify the
            <html:javascrip t> tag when it does the same job that its contemprary <script> tag does? why does this happen...im still unable to figure this bit out...
            does anybody have any answer/or know something regarding this?
            regards,
            ajos

            Comment

            • acoder
              Recognized Expert MVP
              • Nov 2006
              • 16032

              #7
              <html:javascrip t> isn't a valid HTML tag. Is it JSP? If so, you may be having problems with your server-side language code.

              Comment

              • ajos
                Contributor
                • Aug 2007
                • 283

                #8
                Originally posted by acoder
                <html:javascrip t> isn't a valid HTML tag. Is it JSP? If so, you may be having problems with your server-side language code.
                hi acoder thanks again,
                <html:javascrip t> is bundelled with the struts framework..said that it is the same as <script> tag....what i mean to say is that all the other tags(struts) render the same meaning w.r.t normal html tags....
                any way i got my out put using the <script> tag with some modification in the code...also thanks for your valuable time.....i love this site:)
                regards,
                ajos

                Comment

                • dmjpro
                  Top Contributor
                  • Jan 2007
                  • 2476

                  #9
                  Originally posted by ajos
                  hi acoder thanks again,
                  <html:javascrip t> is bundelled with the struts framework..said that it is the same as <script> tag....what i mean to say is that all the other tags(struts) render the same meaning w.r.t normal html tags....
                  any way i got my out put using the <script> tag with some modification in the code...also thanks for your valuable time.....i love this site:)
                  regards,
                  ajos
                  Will you put your whole code here :-)

                  Debasis Jana

                  Comment

                  • ajos
                    Contributor
                    • Aug 2007
                    • 283

                    #10
                    Originally posted by dmjpro
                    Will you put your whole code here :-)

                    Debasis Jana
                    my jsp page?
                    here goes-->
                    [HTML]
                    <%@ page language="java" contentType="te xt/html; charset=ISO-8859-1"
                    pageEncoding="I SO-8859-1"%>
                    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
                    <%@taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
                    <%@taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
                    <%@taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
                    <html:html>
                    <head>
                    <title>Budget Master Administration</title>
                    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
                    <!-- <SCRIPT LANGUAGE="JavaS cript" SRC="bscript.js "></SCRIPT> -->
                    <html:javascrip t src="bscript.js "/>
                    </head>
                    <body topmargin="0" leftmargin="0" bgproperties="f ixed">
                    <div align="left">
                    <html:form action="/BdgtMastAction" name="bdgtmastF orm" type="publicity .BdgtMastForm" method="post" onsubmit="retur n everything(this );">
                    <table border="0" width="100%">
                    <tr>
                    <td width="100%" bgcolor="#DFDFF F" background="ima ges/niceblue.gif">< font face="Tahoma"
                    color="#000000" ><strong>B u d g e t&nbsp;&nbsp; M a s t e r</strong></font></td>
                    </tr>
                    </table>
                    <div align="left">

                    <table width="60%" height="127">
                    <tr>
                    <td valign="top" width="50%" height="34"><st rong><small><fo nt face="Verdana"> </font></small></strong></td>
                    <td width="50%" height="34"></td>
                    </tr>
                    <tr>
                    <td valign="top" width="50%" height="27"><st rong><small><fo nt face="Verdana"> Branch</font></small></strong></td>
                    <td width="50%" height="27">

                    <html:hidden name="bdgtmastF orm" property="optio n" value="new"/>
                    <p>
                    <html:select property="branc h" size="1">
                    <html:option value="Bombay"> </html:option>
                    <html:option value="Ahmedaba d"></html:option>
                    <html:option value="Madras"> </html:option>
                    <html:option value="Bangalor e"></html:option>
                    <html:option value="Calcutta "></html:option>
                    <html:option value="Hyderaba d"></html:option>
                    <html:option value="Pune"></html:option>
                    <html:option value="Lucknow" ></html:option>
                    <html:option value="Jaipur"> </html:option>
                    <html:option value="Patna"></html:option>
                    <html:option value="Cochin"> </html:option>
                    <html:option value="Chandiga rh"></html:option>
                    <html:option value="Bhopal"> </html:option>
                    </html:select>
                    </p>
                    </td>
                    </tr>
                    <tr>
                    <td width="50%" height="25"><st rong><small><fo nt face="Verdana"> Publicity Code </font></small></strong></td>
                    <td width="50%" height="25">
                    <html:text name="bdgtmastF orm" property="publi city_Code" size="5" maxlength="5"></html:text>

                    </tr>
                    <tr>
                    <td width="50%" height="25"><st rong><small><fo nt face="Verdana"> Annual Budget Alloted (<em>Rs</em>)</font></small></strong></td>
                    <td width="50%" height="25">
                    <html:text property="budge t" name="bdgtmastF orm" size="10" maxlength="10" ></html:text>
                    </td>
                    </tr>
                    </table>
                    </div>

                    <p align="left">
                    <!-- <html:button property="thesu bmit" value="Submit" onclick="everyt hing(form)"></html:button> -->
                    <html:submit value="Submit" property="thesu bmit">&nbsp;</html:submit>
                    <!-- <input type="button" name="thesubmit " value="Submit" onclick="everyt hing(form)">&nb sp; -->
                    </p>
                    <hr>
                    <strong><small> <font color="#0080C0" >
                    <p align="center"> ©</font><font color="#0080C0" face="Verdana"> Response - Corporate
                    1998-1999</font></small></strong>
                    </html:form>
                    </div>
                    </body>
                    </html:html>
                    [/HTML]
                    the one in the bold is the problem code.
                    regards,
                    ajos

                    Comment

                    Working...