wood burning stoves 2.0*
The moose likes Servlets and the fly likes importing class to JSP in websphere (newbie) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "importing class to JSP in websphere (newbie) " Watch "importing class to JSP in websphere (newbie) " New topic
Author

importing class to JSP in websphere (newbie)

ann srum
Greenhorn

Joined: Oct 04, 2001
Posts: 5
Hi I am trying to figure out how to properly import a class in a JSP.
The DocumentRoot directory is set in Websphere and that is where my JSP's reside. I have created a folder off of the DocumentRoot directory called classes and placed my .class file in there. I then set the classes directory in the classpath (and restarted the appserver)
I have an import statement in my jsp for the class.
I am now getting an error that says it is unable to compile because of null. Any ideas???
Below is a test piece of JSP code and the class code:
------------------------------------------------------
<%@ page import="java.io.*, java.util.*, java.text.*, IPRStat, java.net.*,java.sql.*"%>
<HTML>
<BODY>
<%
try {
String IPRNum = "001-0001";
String IPRStatus = "OK";
IPRStat Testing = new IPRStat(IPRNum, IPRStatus);
} catch (Exception e) {
out.println("Error detected " + e.getMessage());
}
%>
</BODY>
</HTML>
----------------------------------------------------
class IPRStat
{
public IPRStat(String i, String d )
{
iprnum = i;
status = d;
}
public String getIPRNum()
{
return iprnum;
}
public String getStatus()
{
return status;
}
private String iprnum;
private String status;
}
-----------------------------------------------------
Neha Sharma
Ranch Hand

Joined: Jul 13, 2001
Posts: 126
try using saperate command for each import like
<%@ page import="com.util.DatabaseNames" %>
<%@ page import="com.util.FieldNames" %>
<%@ page import="java.util.*" %>

Neha
ann srum
Greenhorn

Joined: Oct 04, 2001
Posts: 5
I changed the imports to
<%@ page import="java.io.*" %>
<%@ page import="java.util.*"%>
<%@ page import="IPRStat"%>
and still it says (short version of message):
Error Message: Server caught unhandled exception from servlet [JSP 1.1 Processor]: null
Error Code: 500
Target Servlet: JSP 1.1 Processor
Error Stack:
Root Error-1: null

Neha Sharma
Ranch Hand

Joined: Jul 13, 2001
Posts: 126
in your class try by declaring non private variables
Neha
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
having all the imports in one line and having private variables should not matter. what happens if you remove the following code?try to post a longer version of the stack trace if you can.
regards,
-miftah
[This message has been edited by Miftah Khan (edited October 04, 2001).]
ann srum
Greenhorn

Joined: Oct 04, 2001
Posts: 5
If I remove this code "<%@ page import="IPRStat"%>" I get the exact same error as I get when it is there.
A recursive error was detected.
The server cannot use specified error page. Please check the application error-path.
Original Error:
Error Message: Server caught unhandled exception from servlet [JSP 1.1 Processor]: null
Error Code: 500
Target Servlet: JSP 1.1 Processor
Error Stack:
-----------------------------------------------------------------
Root Error-1: null
java.lang.Exception
java/lang/Throwable.<init>(Ljava/lang/String ;)V+4 (Throwable.java:94)
_testidea_jsp_7._jspService(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse ;)V+0 (_testidea_jsp_7.java:50)
javax/servlet/http/HttpServlet.service(Ljavax/servlet/ServletRequest;Ljavax/servlet/ServletResponse ;)V+25 (HttpServlet.java:853)
org/apache/jasper/runtime/JspServlet$JspServletWrapper.service(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;Z)V+210 (JspServlet.java:396)
org/apache/jasper/runtime/JspServlet.serviceJspFile(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;Ljava/lang/String;Ljava/lang/Throwable;Z)V+88 (JspServlet.java:718)
org/apache/jasper/runtime/JspServlet.service(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse ;)V+65 (JspServlet.java:872)
javax/servlet/http/HttpServlet.service(Ljavax/servlet/ServletRequest;Ljavax/servlet/ServletResponse ;)V+25 (HttpServlet.java:853) com/ibm/servlet/engine/webapp/StrictServletInstance.doService(Ljavax/servlet/ServletRequest;Ljavax/servlet/ServletResponse ;)V+21 (ServletManager.java:626) com/ibm/servlet/engine/webapp/StrictLifecycleServlet._service(Ljavax/servlet/ServletRequest;Ljavax/servlet/ServletResponse ;)V+46 (StrictLifecycleServlet.java:160)
com/ibm/servlet/engine/webapp/ServletInstance.service(Ljavax/servlet/ServletRequest;Ljavax/servlet/ServletResponse;Lcom/ibm/servlet/engine/webapp/WebAppServletInvocationEvent ;)V+18 6 (ServletManager.java:360) com/ibm/servlet/engine/webapp/WebAppRequestDispatcher.handleWebAppDispatch(Lcom/ibm/servlet/engine/webapp/WebAppRequest;Ljavax/servlet/http/HttpServletResponse;Z)V+741 (WebAppRequestDispatcher.java:478)
com/ibm/servlet/engine/webapp/WebAppRequestDispatcher.dispatch(Ljavax/servlet/ServletRequest;Ljavax/servlet/ServletResponse;Z)V+443 (WebAppRequestDispatcher.java:234)
com/ibm/servlet/engine/webapp/WebAppRequestDispatcher.forward(Ljavax/servlet/ServletRequest;Ljavax/servlet/ServletResponse ;)V+127 (WebAppRequestDispatcher.java:138) com/ibm/servlet/engine/srt/WebAppInvoker.handleInvocationHook(Ljava/lang/Object ;)V+127 (WebAppInvoker.java:77) com/ibm/servlet/engine/invocation/CachedInvocation.handleInvocation(Ljava/lang/Object ;)V+25 (CachedInvocation.java:67) com/ibm/servlet/engine/invocation/CacheableInvocationContext.invoke(Ljava/lang/Object ;)V+87 (CacheableInvocationContext.java:106) com/ibm/servlet/engine/srp/ServletRequestProcessor.dispatchByURI(Ljava/lang/String;Lcom/ibm/servlet/engine/srp/ISRPConnection ;)V+867 (ServletRequestProcessor.java:160) com/ibm/servlet/engine/oselistener/OSEListenerDispatcher.service(Lcom/ibm/servlet/engine/oselistener/api/IOSEConnection ;)V+95 (OSEListener.java:300) com/ibm/servlet/engine/oselistener/SQEventListenerImp$ServiceRunnable.run()V+155 (SQEventListenerImp.java:230) com/ibm/servlet/engine/oselistener/SQEventListenerImp.notifySQEvent(Lcom/ibm/servlet/engine/oselistener/api/ISQEvent ;)V+184 (SQEventListenerImp.java:104)
com/ibm/servlet/engine/oselistener/serverqueue/SQEventSource.notifyEvent(Lcom/ibm/servlet/engine/oselistener/api/SQEventImp ;)V+40 (SQEventSource.java:212) com/ibm/servlet/engine/oselistener/serverqueue/SQWrapperEventSource$SelectRunnable.notifyService()V+116 (SQWrapperEventSource.java:353) com/ibm/servlet/engine/oselistener/serverqueue/SQWrapperEventSource$SelectRunnable.run()V+124 (SQWrapperEventSource.java:220) com/ibm/servlet/engine/oselistener/outofproc/OutOfProcThread$CtlRunnable.run()V+104 (OutOfProcThread.java:248)
java/lang/Thread.run()V+11 (Thread.java:479)
[This message has been edited by ann srum (edited October 05, 2001).]
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
Actually, according to the longer stack trace your JSP compiled just fine. It's on the execution of the jspService() method that it fails.
If I were you I would look at the java code that is generated and find out what line 50 is doing.
There is an option in WebSphere to keep the compiled JSP code around. You generally set it by using the following steps in WebSphere 3.5.X:
Go to the Administrative Console.
Click the Advanced properties tab for the JSP servlet.
Set Init Parm Name to "keepgenerated"
Set Init Parm Value to "true"
In WebSphere 4.0, do the following:
Use the WebSphere Application Assembly Tool (AAT) to set the Java Server Page attributes keepgenerated=true in the ibm-web- ext.xmi file
Kyle
------------------
Kyle Brown,
Author of Enterprise Java (tm) Programming with IBM Websphere
See my homepage at http://members.aol.com/kgb1001001 for other WebSphere information.
[This message has been edited by Kyle Brown (edited October 05, 2001).]


Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
ann srum
Greenhorn

Joined: Oct 04, 2001
Posts: 5
Finally found the problem!!! Thanks to everyone who offered advice!!!
in the class file I was missing "public"

----> public <---- class IPRStat
{
public IPRStat(String i, String d )
{
iprnum = i;
status = d;
}
public String getIPRNum()
{
return iprnum;
}
public String getStatus()
{
return status;
}
private String iprnum;
private String status;
}

[This message has been edited by ann srum (edited October 05, 2001).]
[This message has been edited by ann srum (edited October 05, 2001).]
Neha Sharma
Ranch Hand

Joined: Jul 13, 2001
Posts: 126
ooh!! baby!! bhaat a mishtik
ann srum
Greenhorn

Joined: Oct 04, 2001
Posts: 5
what does that mean
bhaat a mishtik
Neha Sharma
Ranch Hand

Joined: Jul 13, 2001
Posts: 126
just a distortion of 'What a Mistake'
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: importing class to JSP in websphere (newbie)