Service Desk Practitioners Forum
cancel
Showing results for 
Search instead for 
Did you mean: 

Adding my own JAR file to service pages (10 points for answer)

SOLVED
Go to solution
Highlighted
Elias Abboud
Honored Contributor

Adding my own JAR file to service pages (10 points for answer)

Hello again JSP coders,

I have written a java class then exported it to a JAR file.

Here is some info about it

package com.hp.ov.sd.mypackage;
public class myclass {
public static String Proc1() {
//Do something here
}
}

Then I copied my jar file next to the webapi jar file

Now when I try to import mypackage from within a JSP file using the following syntax:

<%@ page import="com.hp.ov.sd.mypackage" %>

And then I try to access the page I get the error:

Generated servlet error:
myJSPFile_jsp.java:8: cannot resolve symbol
symbol : class myclass
location: package sd
import com.hp.ov.sd.mypackage;

What Am I missing??

If you can't solve it, post it :)
3 REPLIES
Elias Abboud
Honored Contributor

Re: Adding my own JAR file to service pages (10 points for answer)

One Thing to add:

The same code I am running directly from inside the JSP file is working like a charm.

when I want to remove that code from the JSP file and put it in a JAR file then referencing the JAR file to call the functions in it. This is where I am failing.

Can anyone please help
If you can't solve it, post it :)
Gyula Matics_1
Honored Contributor
Solution

Re: Adding my own JAR file to service pages (10 points for answer)

You have to import the Class, not the package. Or all classes in the package.

<%@ page import="com.hp.ov.sd.mypackage.myclass" %>

or

<%@ page import="com.hp.ov.sd.mypackage.*" %>
Elias Abboud
Honored Contributor

Re: Adding my own JAR file to service pages (10 points for answer)

Yeah I already figured that out after some googling but I assigned the 10 points anyway.
If you can't solve it, post it :)
//Add this to "OnDomLoad" event