Problems accesing classes in JSP

Hello, I'm using JRun as a WebServer, Solaris SO and jdk1.2.2.
I made two packages with java files in order to use them in JSP. One package is called entel.wll and it has two classes totally independent, so I compiled them independently and I put the .class files in the following directory structure, i.e: entel/wll/
The other package is called entel.ispchile.util (I want to make more package, of course) There I have two classes, but one is an Interface and the other is a class that implements this interface. Besides the problems that I had to compile this classes, I put the .class files in the following directory structure entel/ispchile/util/
So, I made the jar file by using the following command: jar cvf entel.jar entel/
So, my problem is: When I use a class of the first package I declare the class like that:
Class1 c1 = new Class1();
and I have no problem, but when I declare the second class like that:
Class2 c2 = new Class2();
I have problems because I have an error like: 500 Internal Server Error: Type Class2 Not found
BUT, when I declare the second class like that:
entel.ispchile.util.Class2 c2 = new entel.ispchile.util.Class2() I HAVE NO COMPILATION PROBLEMS...
Please, somebody help me...
Thanks in advance!!

Ya, I just put the page import directive in the .jsp file like:
<%@ page language="java" errorPage="error.jsp" import="java.text.*, java.util.*, entel.wll.*, entel.ispchile.util.*" %>
and I do not understand why the class declared in the package entel.wll works ok, and the class declared in the package entel.ispchile.util doesn't works by declare the class like:
Class2 c2 = new Class2();
instead of that I must declare it like:
entel.ispchile.util.Class2 c2 = new entel.ispchile.util.Class2();
and the class declared in the first package(entel.wll) I can declare it, without problems, like:
Class1 c1 = new Class1();
instead of declare it like:
entel.wll.Class1 c1 = new entel.wll.Class1();

Similar Messages

  • Problem on open Preference in CMC: Unable to compile class for JSP

    Hi all,
    I meet problem when opening Preference in CMC.
    When I click "Web Intelligence" or "Desktop Intelligence", the following message will be display:
    An error has occurred:
    Unable to compile class for JSP
    I have check for catalina.out in tomcat, following error comes out:
    java.io.FileNotFoundException: /opt/boe/bobje/tomcat/work/Catalina/localhost/AnalyticalReporting/org/apache/jsp/jsp/User_005fWebiPreferences/user_005fwebipreferences_jsp.java (No such file or directory)
            at java.io.FileOutputStream.open(Native Method)
            at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
            at java.io.FileOutputStream.<init>(FileOutputStream.java:70)
            at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:140)
            at org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
            at org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
            at org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
            at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
            at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:305)
            at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
            at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
            at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
            at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
            at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
            at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
            at org.apache.struts.action.ActionServlet.processActionForward(ActionServlet.java:1759)
            at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1596)
            at com.businessobjects.webutil.struts.CrystalUTF8InputActionServlet.process(CrystalUTF8InputActionServlet.java:32)
            at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:492)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
            at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
            at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
            at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
            at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
            at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
            at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
            at java.lang.Thread.run(Thread.java:595)
    Please help to indicate where is the problem. Many thanks.
    Regards,
    May

    Hi all,
    I meet problem when opening Preference in CMC.
    When I click "Web Intelligence" or "Desktop Intelligence", the following message will be display:
    An error has occurred:
    Unable to compile class for JSP
    I have check for catalina.out in tomcat, following error comes out:
    java.io.FileNotFoundException: /opt/boe/bobje/tomcat/work/Catalina/localhost/AnalyticalReporting/org/apache/jsp/jsp/User_005fWebiPreferences/user_005fwebipreferences_jsp.java (No such file or directory)
            at java.io.FileOutputStream.open(Native Method)
            at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
            at java.io.FileOutputStream.<init>(FileOutputStream.java:70)
            at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:140)
            at org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
            at org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
            at org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
            at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
            at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:305)
            at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
            at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
            at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
            at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
            at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
            at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
            at org.apache.struts.action.ActionServlet.processActionForward(ActionServlet.java:1759)
            at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1596)
            at com.businessobjects.webutil.struts.CrystalUTF8InputActionServlet.process(CrystalUTF8InputActionServlet.java:32)
            at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:492)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
            at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
            at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
            at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
            at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
            at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
            at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
            at java.lang.Thread.run(Thread.java:595)
    Please help to indicate where is the problem. Many thanks.
    Regards,
    May

  • Problem while trying to execute Java class in JSP using  RunTime Class

    Hi,
    I want to execute a JAVA class through a JSP. For this I am using following code ....
    JSP (AAA.jsp) CODE ............
    try
    String[] cmd = new String[3];
    cmd[0] = "cmd.exe" ;
    cmd[1] = "/C" ;
    cmd[2] = "java -DPeBS_CONFIG_HOME=D:/CASLIntegration/PeBS/srcvob/PeBS/config Service_Statement_Application 22/May/2001 22/May/2003";
    Runtime rt = Runtime.getRuntime();
    System.out.println("Execing " + cmd[0] + " " + cmd[1] + " " + cmd[2]);
    Process proc = rt.exec(cmd);
    // any error message?
    StreamGobbler errorGobbler = new StreamGobbler(proc.getErrorStream(), "ERROR");
    // any output?
    StreamGobbler outputGobbler = new StreamGobbler(proc.getInputStream(), "OUTPUT");
    // kick them off
    errorGobbler.start();
    outputGobbler.start();
    // any error???
    int exitVal = proc.waitFor();
    System.out.println("ExitValue: " + exitVal);
    catch (Throwable t)
    t.printStackTrace();
    StreamGobbler THread class Code ..........
    import java.util.*;
    import java.io.*;
    public class StreamGobbler extends Thread
    InputStream is;
    String type;
    StreamGobbler(InputStream is, String type)
    this.is = is;
    this.type = type;
    public void run()
    try
    InputStreamReader isr = new InputStreamReader(is);
    BufferedReader br = new BufferedReader(isr);
    String line=null;
    while ( (line = br.readLine()) != null)
    System.out.println(type + ">" + line);
    } catch (IOException ioe)
    ioe.printStackTrace();
    I have successfully compiled and placed the class file for the above class in JSP's servlet engine. However, when I execute the JSP through explorer Web Browser, I get following compile time error:
    An error occurred between lines: 36 and 86 in the jsp file: /casl/LocalApp/VehicleServiceStmt/AAA.jsp
    Generated servlet error:
    D:\Tomcat\work\localhost\_\casl\LocalApp\VehicleServiceStmt\AAA$jsp.java:118: No constructor matching StreamGobbler(java.io.InputStream, java.lang.String) found in class StreamGobbler.
    StreamGobbler errorGobbler = new StreamGobbler(proc.getErrorStream(), "ERROR");
    ^
    An error occurred between lines: 36 and 86 in the jsp file: /casl/LocalApp/VehicleServiceStmt/AAA.jsp
    Generated servlet error:
    D:\Tomcat\work\localhost\_\casl\LocalApp\VehicleServiceStmt\AAA$jsp.java:121: No constructor matching StreamGobbler(java.io.InputStream, java.lang.String) found in class StreamGobbler.
    StreamGobbler outputGobbler = new StreamGobbler(proc.getInputStream(), "OUTPUT");
    I am unable to determine the reason of why the constructor which exists in the StreamGobbler Class is not recevied in JSP. If I try to write the same code in JSP as a JAVA class, keeping StreamGobler class same, the programme executes successfully.
    Please help me find solution to this at the earliest. Thanks in advance,
    Prachi

    Thanks,
    I got it working by making the constructor Public.
    -Prachi

  • Problem with JavaBeans in JSP.IT'S URGENT!!!

    Hi, i have problems with JavaBeans in JSP.
    In a jsp file( locating in ROOT directory of tomcat 4.0.6 :jakarta-tomcat-4.0.6\webapps\root ) i have this code:
    <jsp:useBean id="paramBean" class="licentza.ParamBean" />
    <jsp:setProperty name="paramBean"
    property="nume"
              value='<%= request.getParameter("numeUser") %>' />
    where ParamBean it's a "bean" class locating in jakarta-tomcat-4.0.6\webapps\examples\web-inf\classes\licentza (licentza is the package i'm using).
    And i get this error:
    Generated servlet error:
    D:\jakarta-tomcat-4.0.6\work\Standalone\localhost\_\dora\intrare2$jsp.java:67: Class licentza.ParamBean not found.
    ParamBean paramBean = null;
    What is the problem?Thank you.

    Hi,
    Put the class file or the package under :jakarta-tomcat-4.0.6\webapps\root\WEB-INF\classes.
    Rajesh

  • Unable to compile class for JSP

    Please can anyone help me to solve this.
    Actually,this is the condition.
    In my db,there is a table called UserPassword, which has 4
    fields(empNo,UserName,password,level). Now I want to do these things:
    When the user submits the data to create a new account via HTML form, it submits the data to the file called CreateAcc.jsp. In this file it perform some logic,here are they.
    1)To check the empNo,if it is already exist in the DB,
         if empNo =exist then display error.(record already exist)
         if empNo =notexist then do task 2).
    2)check the UserName,if it is already exist in the db,
         if UserName=exist then display error.(because it's a primary key)
         if UserName=notexist then do task 3).
    3)Create a new user account and save it to the db.
    To do these tasks,I never create a new objects for the tasks 1) and 2).
    only for task 3)create an object.
    Is it the right way?
    Here is the file CreateAcc.jsp
    <%@ page language="java" %>
    <%@ page import="core.UserAccManager" %>
    <%@ page import="data.UserPassword" %>
    <jsp:useBean id="UserAccManager" class="core.UserAccManager" scope="session"/>
    <jsp:setProperty name="UserAccManager" property="*"/>
    <jsp:useBean id="UserPassword" class="data.UserPassword" scope="session"/>
    <jsp:setProperty name="UserPassword" property="*"/>
    <%
    String nextPage ="MainForm.jsp";
    if(UserPassword.verifyEmpno()){
         if(UserPassword.verifyUsername()){
              if(UserPassword.createAcc()) nextPage ="MsgAcc.jsp";
          }else{
               nextPage="UserNameExist.jsp";
          else{
              nextPage="UserAccError.jsp";
    %>
    <jsp:forward page="<%=nextPage%>"/>The directory structure:
    UserPassword.java- F:/Project/core/data/UserPassword.java
    UserAccManager.java - F:/Project/core/UserAccManager.java
    Now both are compiling.I put the class files into the TOMCAT,as follows.
    UserAccManager.class - webapps/mySystemName/WEB-INF/classes/core/
    UserPassword.class - webapps/mySystemName/WEB-INF/classes/core/data/
    Here is the full code of the file UserAccManager.java.
    package core;               //Is this right?
    import data.UserPassword;     //Is this right?
    import java.io.*;
    import java.sql.*;
    import java.util.*;
    import javax.sql.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public final class UserAccManager{
       private static final String DRIVER = "com.mysql.jdbc.Driver";
       private static final String URL = "jdbc:mysql://localhost:3306/superfine";
       private static Connection connection;
       private static PreparedStatement pstmt1;
       private static PreparedStatement pstmt2;     
       private static PreparedStatement pstmt3;     
       private UserAccManager(){
       // Initializes the connection and statements
       public static void initConnection() {
          if (connection == null) {
             try {
                String sql;
                // Open the database
                Class.forName(DRIVER).newInstance();
                connection = DriverManager.getConnection(URL);
                // Prepare the statements
               sql = "SELECT * FROM UserPassword where empNo= ?";
               pstmt1 = connection.prepareStatement(sql);
                sql = "SELECT UserName FROM UserPassword where UserName= ?";
                pstmt2 = connection.prepareStatement(sql);
             sql ="INSERT INTO UserPassword VALUES(?,?,?,?)";
             pstmt3 = connection.prepareStatement(sql);
             catch (Exception ex) {
                System.err.println(ex.getMessage());
       // Closes the connection and statements
       // Method to be called by main class when finished with DB
       public  void closeConnection() {
          //same as previous
       public static boolean verifyEmpno(int empno) {
          boolean emp_no_select_ok = false;
          int emp = -1;
          initConnection();
         try {
          pstmt1.setInt(1, empno);
             ResultSet rs1 = pstmt1.executeQuery();
         while(rs1.next()){
              emp=rs1.getInt("empNo");
         if(emp>0)
              emp_no_select_ok = false;
         } else{
              emp_no_select_ok = true;     
            rs1.close();
         pstmt1.close();     
          catch (Exception ex) {
             System.err.println(ex.getMessage());
          return emp_no_select_ok;
       public static boolean verifyUsername(String username) {
          boolean user_name_select_ok = false;
          String user = "xxxx";
          initConnection();
          try {
          pstmt2.setString(1, username);
             ResultSet rs2 = pstmt2.executeQuery();
            while(rs2.next()){
              user=rs2.getString("UserName");
               if(!user.equals("xxxx"))
              user_name_select_ok = false;
            } else{
              user_name_select_ok = true;     
           rs2.close();
          catch (Exception ex) {
             System.err.println(ex.getMessage());
          return user_name_select_ok;
         public static boolean createAcc(int empno, String username, String password, int
    level){
              boolean create_acc_ok = false;
              initConnection();
              try{
                      //create a new object,from the UserPassword table.
                   UserPassword useraccount = new UserPassword();
                   useraccount.setEmpno(empno);
                   useraccount.setUsername(username);
                   useraccount.setPassword(password);
                   useraccount.setLevel(level);
                   //assign value for ???
                   pstmt3.setInt(1, useraccount.getEmpno());
                   pstmt3.setString(2, useraccount.getUsername());
                   pstmt3.setString(3, useraccount.getPassword());
                   pstmt3.setInt(4, useraccount.getLevel());          
                   if(pstmt3.executeUpdate()==1) create_acc_ok=true;
                   pstmt3.close();
                           //con.close();
                catch(SQLException e2){
                           System.err.println(e2.getMessage());
              return create_acc_ok;
    }here is the bean (part of it)
    package data;               //is it right?
    import java.io.*;
    import java.sql.*;
    import java.util.*;
    import javax.sql.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class UserPassword
         private int empno;
         private String username;
         private String password;
         private int level;
         // Constructor
         public UserPassword()
              this.empno = empno;
              this.username = username;
              this.password = password;
              this.level = level;
         // setters and getters are here.
    //     public boolean verifyEmpno() {
    //               return UserAccManager.verifyEmpno(empno);
    //       public boolean verifyUsername(String username) {
    //            return UserAccManager.verifyUsername(username);
         // These 2 methods not compile with or without para's.So I leave that job for the      
         //controll class UserAccManager.java.
    Now my problem is this: When I submit data, there is an error;org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: -1 in the jsp file: null
    Generated servlet error:
    [javac] Compiling 1 source file
    C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\HRM\CreateAcc_jsp.java:8:
    cannot access core.data.UserPassword
    bad class file: C:\Program Files\Apache Group\Tomcat
    4.1\webapps\HRM\WEB-INF\classes\core\data\UserPassword.class
    class file contains wrong class: data.UserPassword
    Please remove or make sure it appears in the correct subdirectory of the classpath.
    import core.data.UserPassword;
    ^
    1 error
    Are there any mistakes? If so tell me where is it and how to change them.Please help.

    I try it that way, but it don't compile.
    Error:core\data\UserPassword.java:package javax.servlet does not exist
    import javax.servlet.*;
    core\data\UserPassword.java:package javax.servlet.http does not exist
    import javax.servlet.http.*;
    So,I comment them only in the UserPassword.java file,and compile it again.
    Then it compile well.I goto the directory to get the .class files.
    But there is only UserPassword.class inside the data folder. There is not
    UserAccManager.class in the core folder.
    Then I try this way,I put my 2 java files in to a new folder,
    F:\SystemName\com
    When I try it that way, but it don't compile.
    javac -classpath . -d . com\*.javaError:com\UserPassword.java:package javax.servlet does not exist
    import javax.servlet.*;
    com\UserPassword.java:package javax.servlet.http does not exist
    import javax.servlet.http.*;
    So,I comment them only in the UserPassword.java file,and compile it again.
    Now both are compiling well.There was 2 class files.
    I put them in to the WEB-INF/classes/com directory.
    Start the server.But it gave errors:
    C:\Program Files\Apache Group\Tomcat
    4.1\work\Standalone\localhost\HRM\CreateAcc_jsp.java:68: cannot resolve symbol
    symbol  : variable empno
    location: class org.apache.jsp.CreateAcc_jsp
    if(UserPassword.verifyEmpno(empno)){
                                ^
    C:\Program Files\Apache Group\Tomcat
    4.1\work\Standalone\localhost\HRM\CreateAcc_jsp.java:69: cannot resolve symbol
    symbol  : variable username
    location: class org.apache.jsp.CreateAcc_jsp
         if(UserAccManager.verifyUsername(username)){
                                             ^
    C:\Program Files\Apache Group\Tomcat
    4.1\work\Standalone\localhost\HRM\CreateAcc_jsp.java:69: non-static method
    verifyUsername(java.lang.String) cannot be referenced from a static context
         if(UserAccManager.verifyUsername(username)){
                             ^
    C:\Program Files\Apache Group\Tomcat
    4.1\work\Standalone\localhost\HRM\CreateAcc_jsp.java:70: cannot resolve symbol
    symbol  : variable empno
    location: class org.apache.jsp.CreateAcc_jsp
              if(UserAccManager.createAcc(empno, username,password,level)) nextPage
    ="MsgAcc.jsp";
                                                ^
    C:\Program Files\Apache Group\Tomcat
    4.1\work\Standalone\localhost\HRM\CreateAcc_jsp.java:70: cannot resolve symbol
    symbol  : variable username
    location: class org.apache.jsp.CreateAcc_jsp
              if(UserAccManager.createAcc(empno, username,password,level)) nextPage
    ="MsgAcc.jsp";
                                                       ^
    C:\Program Files\Apache Group\Tomcat
    4.1\work\Standalone\localhost\HRM\CreateAcc_jsp.java:70: cannot resolve symbol
    symbol  : variable password
    location: class org.apache.jsp.CreateAcc_jsp
              if(UserAccManager.createAcc(empno, username,password,level)) nextPage
    ="MsgAcc.jsp";
                                                                ^
    C:\Program Files\Apache Group\Tomcat
    4.1\work\Standalone\localhost\HRM\CreateAcc_jsp.java:70: cannot resolve symbol
    symbol  : variable level
    location: class org.apache.jsp.CreateAcc_jsp
              if(UserAccManager.createAcc(empno, username,password,level)) nextPage
    ="MsgAcc.jsp";
                                                                         ^
    C:\Program Files\Apache Group\Tomcat
    4.1\work\Standalone\localhost\HRM\CreateAcc_jsp.java:70: non-static method
    createAcc(int,java.lang.String,java.lang.String,int) cannot be referenced from a static
    context
              if(UserAccManager.createAcc(empno, username,password,level)) nextPage
    ="MsgAcc.jsp";
                                     ^
    8 errorsTo solve the problem non-static method,I goto the UserAccManager.java file and do these
    things.
    package com;
    import java.io.*;
    import java.sql.*;
    import java.util.*;
    import javax.sql.*;
    //import javax.servlet.*;               //otherwise it tells an error.(package           
                                  //javax.servlet does not exist)
    //import javax.servlet.http.*;
    public  class UserAccManager {
       private static final String DRIVER = "com.mysql.jdbc.Driver";
       private static final String URL = "jdbc:mysql://localhost:3306/superfine";
       private static Connection connection;
       private static PreparedStatement pstmt1;
        private static PreparedStatement pstmt2;
          private static PreparedStatement pstmt3;
       private UserAccManager() {
       // Initializes the connection and statements
       private static void initConnection() {
             //same
       // Closes the connection and statements
       // Method to be called by main class when finished with DB
       public static void closeConnection() {
         //same
       public static boolean verifyEmpno(int empno) {
          // same.
       public static boolean verifyUsername(String username) {
         //same.
         public static boolean createAcc(int empno, String username, String password, int      
    level){
              //same
    package com;
    import java.io.*;
    import java.sql.*;
    import java.util.*;
    import javax.sql.*;
    //import javax.servlet.*;
    //import javax.servlet.http.*;
    public class UserPassword {
         // same
    Again compile those files and put .class filses into the WEB-INF/classes/com directory.
    When i submits the data via the form it generates an error:
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: 9 in the jsp file: /CreateAcc.jsp
    Generated servlet error:
        [javac] Compiling 1 source file
    C:\Program Files\Apache Group\Tomcat
    4.1\work\Standalone\localhost\HRM\CreateAcc_jsp.java:68: cannot resolve symbol
    symbol  : variable empno
    location: class org.apache.jsp.CreateAcc_jsp
    if(UserAccManager.verifyEmpno(empno)){
                                  ^
    An error occurred at line: 9 in the jsp file: /CreateAcc.jsp
    Generated servlet error:
    C:\Program Files\Apache Group\Tomcat
    4.1\work\Standalone\localhost\HRM\CreateAcc_jsp.java:69: cannot resolve symbol
    symbol  : variable username
    location: class org.apache.jsp.CreateAcc_jsp
         if(UserAccManager.verifyUsername(username)){
                                             ^
    An error occurred at line: 9 in the jsp file: /CreateAcc.jsp
    Generated servlet error:
    C:\Program Files\Apache Group\Tomcat
    4.1\work\Standalone\localhost\HRM\CreateAcc_jsp.java:70: cannot resolve symbol
    symbol  : variable empno
    location: class org.apache.jsp.CreateAcc_jsp
              if(UserAccManager.createAcc(empno, username,password,level)) nextPage
    ="MsgAcc.jsp";
                                                ^
    An error occurred at line: 9 in the jsp file: /CreateAcc.jsp
    Generated servlet error:
    C:\Program Files\Apache Group\Tomcat
    4.1\work\Standalone\localhost\HRM\CreateAcc_jsp.java:70: cannot resolve symbol
    symbol  : variable username
    location: class org.apache.jsp.CreateAcc_jsp
              if(UserAccManager.createAcc(empno, username,password,level)) nextPage
    ="MsgAcc.jsp";
                                                       ^
    An error occurred at line: 9 in the jsp file: /CreateAcc.jsp
    Generated servlet error:
    C:\Program Files\Apache Group\Tomcat
    4.1\work\Standalone\localhost\HRM\CreateAcc_jsp.java:70: cannot resolve symbol
    symbol  : variable password
    location: class org.apache.jsp.CreateAcc_jsp
              if(UserAccManager.createAcc(empno, username,password,level)) nextPage
    ="MsgAcc.jsp";
                                                                ^
    An error occurred at line: 9 in the jsp file: /CreateAcc.jsp
    Generated servlet error:
    C:\Program Files\Apache Group\Tomcat
    4.1\work\Standalone\localhost\HRM\CreateAcc_jsp.java:70: cannot resolve symbol
    symbol  : variable level
    location: class org.apache.jsp.CreateAcc_jsp
              if(UserAccManager.createAcc(empno, username,password,level)) nextPage
    ="MsgAcc.jsp";
                                                                         ^
    6 errorshere is the CreateAcc.jsp file
    <%@ page language="java" %>
    <%@ page import="com.UserAccManager" %>
    <%@ page import="com.UserPassword" %>
    <jsp:useBean id="userPassword" class="com.UserPassword" scope="request"/>
    <jsp:setProperty name="userPassword" property="*" />
    <%
    String nextPage ="MainForm.jsp";
    if(UserAccManager.verifyEmpno(empno)){
         if(UserAccManager.verifyUsername(username)){
              if(UserAccManager.createAcc(empno, username,password,level)) nextPage
    ="MsgAcc.jsp";
          }else{
               nextPage="UserNameExist.jsp";
          else{
              nextPage="UserAccError.jsp";
    %>
    <jsp:forward page="<%=nextPage%>"/>Please, anyone know how to send these parameters to the java file.
    Thanks.

  • Can't import class into JSP

    Hi,
    I am trying to import a class into my JSP and am getting the following error at runtime:
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: -1 in the jsp file: null
    Generated servlet error:
    [javac] Compiling 1 source file
    [javac] D:\jwsdp-1.2\work\Catalina\localhost\pe\org\apache\jsp\guestbook_jsp.java:7: '.' expected
    [javac] import MessageGetter;
    My import statement in the JSP is simply:
    <%@ page import="MessageGetter" %>
    and I am placing the class in the WEB-INF/classes directory. This is stumping me - if you've come across this or a similar problem, please let me know. Thanks.
    P

    Try posting your question in the JSP forum (http://forum.java.sun.com/forum.jsp?forum=45)
    cheers,
    Mike

  • Unable to compil class for jsp

    error is
    HTTP Status 500 -
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: Unable to compile class for JSP:
    An error occurred at line: 6 in the generated java file
    Syntax error on token ".", Identifier expected after this token
    An error occurred at line: 7 in the generated java file
    Syntax error on token ".", Identifier expected after this token
    An error occurred at line: 9 in the jsp file: /travel/issue.jsp
    LibraryStudent cannot be resolved to a type
    6: <BODY>
    7: <H1>issue books</H1>
    8: <CENTER>
    9: <jsp:useBean id="student"
    10: type="LibraryStudent"
    11: scope="session" />
    12: student name:
    An error occurred at line: 9 in the jsp file: /travel/issue.jsp
    LibraryStudent cannot be resolved to a type
    6: <BODY>
    7: <H1>issue books</H1>
    8: <CENTER>
    9: <jsp:useBean id="student"
    10: type="LibraryStudent"
    11: scope="session" />
    12: student name:
    An error occurred at line: 13 in the jsp file: /travel/issue.jsp
    LibraryStudent cannot be resolved to a type
    10: type="LibraryStudent"
    11: scope="session" />
    12: student name:
    13: <jsp:getProperty name="student" property="studentName" />
    14:
    15: book name:
    16: <jsp:getProperty name="student" property="bookName" />
    An error occurred at line: 16 in the jsp file: /travel/issue.jsp
    LibraryStudent cannot be resolved to a type
    13: <jsp:getProperty name="student" property="studentName" />
    14:
    15: book name:
    16: <jsp:getProperty name="student" property="bookName" />
    17:
    18: <jsp:getProperty name="student"
    19: property="issueData" />
    An error occurred at line: 18 in the jsp file: /travel/issue.jsp
    LibraryStudent cannot be resolved to a type
    15: book name:
    16: <jsp:getProperty name="student" property="bookName" />
    17:
    18: <jsp:getProperty name="student"
    19: property="issueData" />
    20: </FORM>
    21: </CENTER>LibraryStudent.java is   
    import java.util.*;
    import java.text.*;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import java.util.*;
    public class LibraryStudent {
    private String emailAddress, s,password, sname,bname;
    private String date,value;
    public String getStudentName() {
    return(sname);
    public void setStudentName(String sname) {
    this.sname = sname;
    public String getEmailAddress() {
    return(emailAddress);
    public void setEmailAddress(String emailAddress) {
    this.emailAddress = emailAddress;
    public String getPassword() {
    return(password);
    public void setPassword(String password) {
    this.password = password;
    public String getBookName() {
    return(bname);
    public void setBookName(String bname) {
    this.bname = bname;
    public String getDate() {
    return(date);
    public void setDate(String date) {
    this.date = date;
    public String getIssueData() //method that create connection withh database
    throws ServletException,IOException{
    try{
    getDate();                   //and add a entry in database
    getBookName();
    getStudentName();
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con=DriverManager.getConnection("jdbc:odbc:db2");
    Statement st=con.createStatement();
    String sql =
        "insert into table1 (bookname,studentname,date) values(bname,sname,date)";
      st.executeUpdate(sql);
    System.out.println(sql);
    String s=  "your book has been issued ";
    return(s);
    catch(Exception e)
    e.printStackTrace();
    return "failed";
    public String getSumbitData()
    throws ServletException,IOException{
    try
    getBookName();
    getStudentName();
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con=DriverManager.getConnection("jdbc:odbc:db2");
    Statement st=con.createStatement();
    String sql =
        "delete from db2 where bookname='bname' and studentname=sname";
      st.executeUpdate(sql);
    System.out.println(sql);
    String s="your book has been sumbitted ";
    return(s) ;
    catch(Exception e)
    e.printStackTrace();
    return "failed";
    public static int findStudent    //to validate customer
    (String emailAddress,
    String password) throws ServletException,IOException{
    try
    if (emailAddress == null) {
    return(0);
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con=DriverManager.getConnection("jdbc:odbc:user");
    Statement st=con.createStatement();
    String sql="select * from user where name='"+emailAddress+"' and password='"+password+"'";
    System.out.println(sql);
    ResultSet rs=st.executeQuery(sql);
    if(rs.next())
    return(1);
    else
    return(0);
    }catch(Exception e)
    e.printStackTrace();
    return (0);}
      to be continued.............

    and Library.java is import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class Library extends HttpServlet {
    public void doPost(HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException {
    String emailAddress = request.getParameter("emailAddress");//use to email&pass
    String password = request.getParameter("password");//from html page
    LibraryStudent student = new LibraryStudent();//Make a student Object
    int a=LibraryStudent.findStudent(emailAddress, password);//to validate student
    if (a==0) {
    gotoPage("/library/accounts.jsp", request, response);
    else
    student.setStudentName(request.getParameter("sname"));//use to sent other textbox
    student.setBookName(request.getParameter("bname"));//data in librarystudent
    student.setDate(request.getParameter("date"));//class after validation
    HttpSession session = request.getSession(true);
    session.putValue("student", student);
    //for moving different page
    if (request.getParameter("issue") != null) {
    gotoPage("/travel/issue.jsp",
    request, response);
    } else if (request.getParameter("sumbit") != null) {
    gotoPage("/travel/sumbit.jsp",
    request, response);
    } else if (request.getParameter("search") != null) {
    gotoPage("/travel/search.jsp",
    request, response);
    } else if (request.getParameter("account") != null) {
    gotoPage("/travel/EditAccounts.jsp",
    request, response);
    } else {
    gotoPage("/travel/IllegalRequest.jsp",
    request, response);
    private void gotoPage(String address,
    HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException {
    RequestDispatcher dispatcher =
    getServletContext().getRequestDispatcher(address);
    dispatcher.forward(request, response);
    }    issue.jsp is
       <%@page import="java.io.,java.util.,java.sql.*"%>
    <HTML>
    <HEAD>
    <TITLE>issue books</TITLE>
    </HEAD>
    <BODY>
    <H1>issue books</H1>
    <CENTER>
    <jsp:useBean id="student"
    type="LibraryStudent"
    scope="session" />
    student name:
    <jsp:getProperty name="student" property="studentName" />
    book name:
    <jsp:getProperty name="student" property="bookName" />
    <jsp:getProperty name="student"
    property="issueData" />
    </FORM>
    </CENTER>
    </BODY>
    </HTML> plz solve my problem .i m new to servlet and jsp and i have keen desire to learn this topic

  • Problem importing classes and beans

    Hey there. Im having one major fustrating problem! When I code supporting classes and beans for my JSPs I get a code 500 internal server error when trying to import (via <%@ page import="class" %> and <jsp:useBean/>) Im storing my classes and beans in the WEB-INF folder and the calling JSPs are located in /ROOT/tests/8/jsp.jsp. Im using the following to import a class or bean:
    <%@ import="aClass" %>
    Seen as tho its in the WEB-INF folder I won't have to explicitly refer to where the class is located, just the class name.
    I never had this problem when I was using my hosting service. Its only on my localhost server in which I get the Internal Server error.
    Help appreciated, thx.
    PS: Im quite new to JSP/Java Servlet.

    import (via <%@ page import="class" %> and
    <jsp:useBean/>) Im storing my classes and beans in the
    WEB-INF folder try put your class file in WEB-INF/classes.
    or first put bean in the package, like WEB-INF/classes/packagename/beanclass
    in jsp page:
    <jsp:useBean id="Mybean" class="packagename.beanclass" scope="request" />
    Question: is /ROOT a context entry in your server.xml?
    Which JSP Container (version) you use? Maybe your localhost server's set up is different with your hosting.

  • Problem in Frame and JSP

    hi all,
    i built an web application and now i want to add a menu using frame in HTML or javascript. The problem is all my JSP pages are data dependant from one another that means sometimes i am sending the data using input boxes and sometimes using HIDDEN values in HTML. Now i tried this followig way to use frame and to send my data to other pages but it is not working can anyone please help me.
    "DOES ANYONE KNOW WHETHER I CAN USE FRAME IN THE JSP PAGE OR NOT"
    LOGIN.HTML
    <form action="startframe.html" method="post">
    <center><h2>Employee Number:</h2></center>
    <center><input type="text" name="emplno" maxlength="4"size="4"></center></br>
    <center><h2>Password:</h2></center>
    <center><input type="password" name="pass" maxlength="6" size="6"></center></br>
    <center><input type="submit" value="SUBMIT YOUR INFO"></center>
    </form>
    </body>
    </html> DATA are GOING FROM LOGIN.HTML TO VARIFYLOGIN.JSP
    Now in between these two i used an HTML file to place a frame so that i can use the frame and the code is:
    <HTML>
    <HEAD>
    <TITLE> </TITLE>
    <frameset cols="15%,85%">>
    <frame name="frame1" src="buttons.html">
    <frame name="frame2" src="varifylogin.jsp?emplno=<%=emplno%> &pass=<%=pass%>" >
    </frameset>
    </HEAD>
    <BODY>
    </BODY>
    </HTML> "DOES ANYONE KNOW WHETHER I CAN USE FRAME IN THE JSP PAGE OR NOT"
    and then it should go to VARIFYLOGIN.JSP which is:
    String empl_no = request.getParameter("emplno");
       String password=request.getParameter("pass");
       Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
       Connection con = DriverManager.getConnection("jdbc:odbc:finalmp" );
       Statement stmt = con.createStatement();
       ResultSet rs = stmt.executeQuery("SELECT StaffID,FirstName,LastName,Password FROM StaffDetails");...................................................etc.
    i am getting this error on the RIGHT hand side frame meaning it showing the buttons on the left but this error on the right:
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:367)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:293)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    root cause
    java.lang.NullPointerException
         org.apache.jsp.varifylogin_jsp._jspService(varifylogin_jsp.java:83)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:136)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:320)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:293)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:856Can anyone please help me.
    Cheers

    i am working in jubuilder
    and have made there three forms,and
    calling s-aots and st_aots in fs_aots
    but when i compile
    it takes fiel,d text on seprate page display result on other window
    why it dosent use frame here
    2nd thing
    i want to enable scrolling
    how i can do
    or how can i display required no of records in second row
    if i mention page size in any check box
    <html>
    <head>
    <title>
    fs_aots
    </title>
    </head>
    <jsp:useBean id="fs_aotsBeanId" scope="session" class="s_aots.fs_aotsBean" />
    <jsp:setProperty name="fs_aotsBeanId" property="*" />
    <body>
    <FRAMESET Rows="30%" Framespacing="0">
    <Frame Name ="Header" SRC="s_aots.jsp" Frameborder="0" Scrolling="no">
    <FRAMESET Rows="70%" Framespacing="0">
    <Frame Name="data" SRC="st_aots.jsp" Frameborder="0" Scrolling="yes">
    </frameset>
    </frameset>
    </BODY>
    </html>
    <html>
    <head>
    <title>
    s_aots
    </title>
    </head>
    <jsp:useBean id="s_aotsBeanId" scope="session" class="s_aots.s_aotsBean" />
    <jsp:setProperty name="s_aotsBeanId" property="*" />
    <body>
    <p>update database content
    <form action="st_aots.jsp" method="post">
    Region<input type=text name=Regionparam><br>
    Bill Month From :<input type=text name=BmonthFparam><br>
    Bill Month To:<input type=text name=BmonthTparam><br>
    Connection Type:<input type=text name=Conntypeparam><br>
    Exchanges:<input type=text name=Exchparam><br>
    Phone No:<input type=text name=PhoneNoparam><br>
    <input type=Submit value="Retrive from DB">
    </form>
    </BODY>
    </HTML>
    <html>
    <head>
    <title>
    st_aots
    </title>
    </head>
    <jsp:useBean id="st_aotsBeanId" scope="session" class="s_aots.st_aotsBean" />
    <jsp:setProperty name="st_aotsBeanId" property="*" />
    <%@ page language="java" import="java.util.*"%>
    <table border=1 cellpadding=0 cellspacing=0 >
    <tr><td> Phone No: </td>
    <td> Current Bill: </td>
    <td> Net Payable: </td>
    <td>Net Arrers:</td>
    <td>customer Name:</td>
    <td>Customer Address:</td>
    <td>Connection Type:</td>
    </tr>
    <%
      Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
      java.sql.Connection connection = java.sql.DriverManager.getConnection("jdbc:odbc:AOTS4");
      java.sql.Statement statement = connection.createStatement();
      Enumeration parameters = request.getParameterNames();
        if(parameters.hasMoreElements()){
        String REGION = request.getParameter("Regionparam");
        String BILL_MONTH_FROM = request.getParameter("BmonthFparam");
        String BILL_MONTH_TO = request.getParameter("BmonthTparam");
        String CONN_TYPE = request.getParameter("Conntypeparam");
        String EXCHANGES = request.getParameter("Exchparam");
        String PHONE = request.getParameter("PhoneNoparam");
       //String q;
       // statement.executeUpdate("INSERT INTO updatephonebook (LAST,FIRST,PHONE) VALUES ('"+LastValue+"','"+FirstValue+"','"+PhoneValue+"')");
    // q= " SELECT PHONE_NO,GROSS_CURRENT_BILL,AMOUNT_PAYABLE,NET_ARRERS_AMOUNT,NAME,ADDRESS_1,ADDRESS_2,ADDRESS_3,ADDRESS_4,CONNECTION_TYPE FROM AOTS WHERE REGION_CODE='" +REGION+ "' AND BILL_PERIOD BETWEEN '" + BILL_MONTH_FROM + "' AND '"+BILL_MONTH_TO+"' AND CONNECTION_TYPE='"+CONN_TYPE+"' AND EXCHANGE_CODE='"+EXCHANGES+"' AND PHONE_NO='"+PHONE+"'";
       // System.out.println(q);
         java.sql.ResultSet columns = statement.executeQuery
        (" SELECT PHONE_NO,GROSS_CURRENT_BILL,AMOUNT_PAYABLE,NET_ARRERS_AMOUNT,NAME,ADDRESS_1,ADDRESS_2,ADDRESS_3,ADDRESS_4,CONNECTION_TYPE FROM AOTS4 WHERE REGION_CODE='" +REGION+ "' AND (BILL_PERIOD BETWEEN '"+BILL_MONTH_FROM+"' AND '"+BILL_MONTH_TO+"') AND CONNECTION_TYPE='"+CONN_TYPE+"' AND EXCHANGE_CODE='"+EXCHANGES+"' AND PHONE_NO='"+PHONE+"' ")  ;
        //(" SELECT PHONE_NO,GROSS_CURRENT_BILL,AMOUNT_PAYABLE,NET_ARRERS_AMOUNT,NAME,ADDRESS_1,ADDRESS_2,ADDRESS_3,ADDRESS_4,CONNECTION_TYPE FROM AOTS4 WHERE REGION_CODE='" +REGION+ "' AND CONNECTION_TYPE='"+CONN_TYPE+"' AND EXCHANGE_CODE='"+EXCHANGES+"' AND PHONE_NO='"+PHONE+"' ")  ;
         // java.sql.ResultSet columns = statement.executeQuery(q);
       // String sql =  ("SELECT BILL_PERIOD,REGION_CODE,EXCHANGE_CODE,PHONE_NO,GROSS_CURRENT_BILL,AMOUNT_PAYABLE,NET_ARRERS_AMOUNT,NAME,ADDRESS_1,ADDRESS_2,ADDRESS_3,ADDRESS_4,CONNECTION_TYPE FROM AOTS WHERE REGION_CODE ='"+REGION+"' AND (BILL_PERIOD BETWEEN '"+BILL_MONTH_FROM+"' AND '"+BILL_MONTH_TO+"') AND CONNECTION_TYPE='"+CONN_TYPE+"' AND EXCHANGE_CODE = '"+EXCHANGES+"' AND PHONE_NO='"+PHONE+"') " );
         //System.out.println("THE SQL QUERY = " + sql);
          //java.sql.ResultSet columns = statement.executeQuery(sql);
                                while(columns.next()){
                                String Phone_No = columns.getString("PHONE_NO");
                                String G_C_Bill = columns.getString("GROSS_CURRENT_BILL");
                                String Amount_Payable= columns.getString("AMOUNT_PAYABLE");
                                String N_A_Amount= columns.getString("NET_ARRERS_AMOUNT");
                                String Name= columns.getString("NAME");
                                String Address1= columns.getString("ADDRESS_1");
                                String Address2= columns.getString("ADDRESS_2");
                                String Address3= columns.getString("ADDRESS_3");
                                String Address4= columns.getString("ADDRESS_4");
                                String C_Type= columns.getString("CONNECTION_TYPE");
    %>
                                <TR>
                                <TD> <%=Phone_No %></td>
                                <TD> <%=G_C_Bill %></td>
                                <TD> <%=Amount_Payable%></td>
                                <TD> <%=N_A_Amount %></td>
                                <TD> <%=Name %></td>
                                <TD> <%=Address1 %>,<%=Address2%>,<%=Address3%>,<%=Address4%></td>
                                <TD> <%=C_Type %></td>
                                </tr>
                                <%}
    }%>
                                </table>
                                </body>
                                </html>

  • NullPointerException - importing my own class to JSP

    Hi.
    I'm writing a JSP page. I also made a class in WEB-INF/classes/org/MyXml.class. When I try to run this class from console, there is no problems at all. But if i try to use function from that class in JSP, i get this (the same error i get whichever function i try to use (btw, all functions are static, as they should be, right?)):
    java.lang.NullPointerException
         org.MyXml.CountProducts(MyXml.java:46)
         org.apache.jsp.index_jsp._jspService(index_jsp.java:75)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    I used this class like this:
    <%@ page import="org.MyXml" %>
    <%
    MyXml.CountProducts();
    %>
    I'm also a bit confused, it says that error is on line 46. Well, there's just a comment!
    Please help. Thanks.

    pqeuens,
    MyXml is his class. his methods are static, so, import="org.MyXml.*" won't work. It would either be import="org.*" or import="org.MyXml" (which he has)
    paull1911
    "What file are you looking at to find line 46? It is the java file (a servlet) corresponding to the jsp file."
    It should actually be in the org.MyXml.java file. The stack trace line is:
    java.lang.NullPointerException
    org.MyXml.CountProducts(MyXml.java:46)
    someone_
    You know from the above error line that the error is in MyXml.CountProducts method. After making sure you are working with the most up-to-date version of the class, (if that doesn't help you get a more accurate line number) walk through the CountProducts method and see where you might be trying to access an object that has not yet been instantiated (either using someObject.someMethodOrMember, or someArray[index])

  • ACK! Importing classes in JSP?!?! HELP!!!

    I am REALLY new to the JSP world and just finished creating a java applet that creates a graph and two combo boxes containing information that I need to display on a web page.
    The problem is that I have just been told to convert it to JSP? Is this possible? If it IS possible, how do you import a public class into JSP?
    Thanks sooooo much for your help!!!!!
    Adam

    Answer is yes you can import a java class
    Here is how it works
    use the following
    <%@ page import="com.temp.YourClass*" %>
    Assuming that you classpath is set properly
    Thanks
    Sampath Thummati.

  • Declaring public class in JSP environment.

    Can anybody please tell me, what technical implication can occur, if we declare a public java class inside JSP.
    The scenario is -
    I have a JSP file used to display the results in table format.
    Before displaying the table, a public class is defined in the same JSP.
    Inside the scriptlet, the object is instantiated (using 'new' keyword).
    That object is used to populate the table.
    I know that according to the MVC architecture, the presentation logic should not be intermingled with the business logic. But I wanted to know whether any 'technical' problems we can face because of this.
    For e.g. Synchronization problem or singleton object creation problem etc.

    Yes its like a inner class, and will be available only to the current JSP.
    The code structure is somewhat like this -
    <%!
    public class SearchCN{
         String strUserName;
         String strPassword;
         Context context = null;
    %>
    <%
    SearchCN searchObject = new SearchCN();
    obj.connect();
    %>
    Now in such a scenario, I can think of some causes like, if N no of users open the same JSP, then N connections will get created. Connection sharing which could have been implemented for better performance is not possible.
    Can you give any additional inputs?

  • Classes in JSP, Overloading of constructor (parametric constructor)

    Classes in JSP, Overloading of constructor (parametric constructor)
    I have created a Java class in JSP and created new objects, no problem.
    I have also manage to overload methods like
    writeOut() {}
    writeOut(String arg) {}
    writeOut(String arg, String arg2) {}
    But, i have a problem a parametric constructor (parametric constructor).
    Like if the class looks like this :
    class Test {
    public void Test() {}
    public void Test(String arg) {}
    public void Test(String arg, String arg2) {}
    I manage to compile this, but when i try to execute the parametric constructor by this code :
    <%Test objTest = new Test("value");%>
    I get 1 warning, and i do have a constructor that is like this :
    public void Test(String arg, String arg2) {....}
    C:\Program Files\Apache Tomcat 4.0\work\localhost\_\nils\slett-kode\test$jsp.java:114: Wrong number of arguments in constructor.
    Test objTest = new Test("hei","had");
    ^
    Note: C:\Program Files\Apache Tomcat 4.0\work\localhost\_\nils\slett-kode\test$jsp.java uses or overrides a deprecated API. Recompile with "-deprecation" for details.
    1 error, 1 warning
    Can anyone please help me, or tell me if i can have parametric constructor in JSP ?

    If it's still not working right, I'd suggest making sure that you don't have an old copy of the class file somewhere on your box that might be accessed instead of the one you really want it to. But yes, the following code executes fine..
    class Test
        public Test()
            System.out.println("In Test()");
        public Test(String arg)
            System.out.println("In Test(String)");
        public Test(String arg1, String arg2)
            System.out.println("In Test(String, String)");
        public static void main(String[] argv)
            Test test = new Test();
            Test test2 = new Test("hello");
            Test test3 = new Test("hello", "world");
    }And outputs the lines
    In Test()
    In Test(String)
    In Test(String, String)

  • Problems with filters and jsp pages.

    I have the following simple filter that checks if there is user information in the session object and redirects accordingly:
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class LoginFilter implements Filter
         public void init(FilterConfig filterConfig) {}
         public void destroy() {}
         public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
         throws IOException, ServletException
              System.out.println("filter");
              HttpSession session = ((HttpServletRequest)request).getSession();
              String action = request.getParameter("action");
              if(action != null && !action.equals("login") && !action.equals("wronglogin"))
                   if(session.getAttribute("username") == null)
                        ((HttpServletResponse)response).sendRedirect("index.jsp?action=wronglogin");
                        System.out.println("User not OK, kicking out...");
                   else
                        chain.doFilter(request, response);
                        System.out.println("User OK, letting in...");
              else
                   chain.doFilter(request, response);
    }The filter is mapped to an admin page with the name index.jsp. However, I get an error for every <% and %> tag in the file (there are quite a few) when I use the filter with the page. The page works fine without the filter, and the filter seems to work with pages without scriptlets (without the <% and %> tags). Here is the beginning of the error report:
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: 6 in the jsp file: /admin/index.jsp
    Generated servlet error:
    Syntax error on tokens, AnnotationName expected instead
    An error occurred at line: 6 in the jsp file: /admin/index.jsp
    Generated servlet error:
    Syntax error on tokens, delete these tokens
    An error occurred at line: 6 in the jsp file: /admin/index.jsp
    Generated servlet error:
    Syntax error on token ";", [ expected
    An error occurred at line: 6 in the jsp file: /admin/index.jsp
    Generated servlet error:
    Syntax error on token ";", [ expected
    An error occurred at line: 6 in the jsp file: /admin/index.jsp
    Generated servlet error:
    Syntax error on token ";", [ expected
    Jasper gives me many errors per <% and %> tag. As you can see there is a <% tag on line 6. Any idea, why this does not work?
    Thanks!
    Message was edited by:
    chincillya

    What is the JSP scriptlet code at line 6 ?
    By looking at the code we can identify if there are any syntax errors, otherwise we can't really guess what might be the problem.

  • Error: cannot access class oracle.jsp.runtime.HttpJsp; file oracle\jsp\runtime\HttpJs

    Hello,
    where is now oracle\jsp\runtime\HttpJsp.class located?
    thanks.
    Oleg.

    Same problem,
    Error: cannot access class oracle.jsp.runtime.HttpJsp; file oracle\jsp\runtime\HttpJsp.class not found
    Thanks
    aldo

Maybe you are looking for

  • Convenience key

    How do I change to make another thing like my contacts or voice dialing or vibrate mode Solved! Go to Solution.

  • HR module issue

    hi i am using BAPI_HELPVALUES_GET function module, through this i get employee group and employee subgroups separately, therefore my issue is how to find employee subgroup is of which employee group in bapi function module itself???? i am executing b

  • Using scan from string to convert a string into a number

    I wanted to use scan from string to change a string into a decimal number, but when the string is, for example, 9.14123E-2 it just returns 10. How can I get it to return .00914 or 9.14E-2(as a number not a string). Would there be something easier tha

  • Failed Call Centre Support

    Last month, I contacted BT asking if my exchange is getting an upgrade or not, and one of the guys at call centre said that my exchange will get fibre optic today (2nd February). Today, I've been checking the BT Infinity availability and it says I on

  • Very slow network printing in Mac os 10.6

    Hi, I am printing to a HP2035n. A networked printer. I bought it while I still had 10.5 It worked like a charm - very fast. I upgraded to Snow Leopard (10.6) with a new hard disk in the laptop. After this, the printing is very slow. Painfully slow. T