aspose file tools*
The moose likes Servlets and the fly likes calling java files from jsp page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "calling java files from jsp page" Watch "calling java files from jsp page" New topic
Author

calling java files from jsp page

kevin schmidt
Ranch Hand

Joined: Aug 24, 2001
Posts: 85
Hi,
I'm having problems now trying to access a java file from a jsp page. In the page I am calling "processName newName = new processName(newsName)". I have a java/class file called processName. The server gives me this error:
"Class _jsps._test._kevin._n_00025ws.processName not found. processName newName = new processName(newsName);"
How can I call this file from a JSP page, or do I have to place the code directly into the page? Or is a servlet the easier way to go about this? Thanks
Oh, by the way, this is all done on iPlanet Web Server 4.1
[This message has been edited by kevin schmidt (edited August 29, 2001).]
Joey Duguay
Greenhorn

Joined: Aug 27, 2001
Posts: 11
From the looks of it you are not importing the java file you want to use. Here is how you import that file.
Here is an example of importing the Vector class
<%@ page language="java" import="java.util.Vector" %>
After that the class is available to be used by the JSP.
Put the import statement at the top of your JSP page.
Joey
kevin schmidt
Ranch Hand

Joined: Aug 24, 2001
Posts: 85
I have the <%@ page import... at the top of the page, but do I have to import the file I created? And if so, how do I do that?
Joey Duguay
Greenhorn

Joined: Aug 27, 2001
Posts: 11
Yes, you do need to import the class you created.
So you will have to add processName to the import statement. Now you must specify which package, if any your class belongs to. For example. If you compiled the class and have a package statement in it like this.
package foo.net;
Then you would have to add foo.net.processName to the import statement. If it doesn't belong to a package, as long as the folder where the class is located is in your classpath you just need to add processName to the import statement.
If this is not clear paste your import statement here so we can look at what is wrong.
Joey
kevin schmidt
Ranch Hand

Joined: Aug 24, 2001
Posts: 85
OK, the classpath contains the path to the directory that contains the .class file. My .jsp and .class files are all in this directory. My page still doesn't work, it says:
"Class processName not found in import. import processName;"
This is what I have at the top of my jsp page:
<%@ page import="processName" %>
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15632
    
  15

Let's assume I have a class in package com.javaranch.thingies.
<%@ page language="java" import="com.javaranch.thingies.*" %>
Now in WEB-INF\classes\com\javaranch\thingies\ I'll have my class files. Say maybe "Thingy1.class".
I should now be able to do what I want:
<% com.javaranch.thingies.Thingy1 theThing = new com.javaranch.thingies.Thingy1();
%>
Of course, since there's an import in effect, the package path on that last snippet is optional (unless I have some other package that has a Thingy1 class in it too!)
[This message has been edited by Tim Holloway (edited August 30, 2001).]


Customer surveys are for companies who didn't pay proper attention to begin with.
kevin schmidt
Ranch Hand

Joined: Aug 24, 2001
Posts: 85
OK,
Now I have the file imported and the page works. Thanks for that help. But now, I need to return the information I want from the java files to my jsp page. The information coming from the java files is used as information on my main page and is beign returned in a String format. How do I go about returning the String and using it in the JSP page? Thanks.
[This message has been edited by kevin schmidt (edited August 30, 2001).]
dexter ferreira
Greenhorn

Joined: Feb 16, 2001
Posts: 7

You can return an object that encapsulates the data you require in ur page or you can use a bean along with the jsp:use bean tag.
kevin schmidt
Ranch Hand

Joined: Aug 24, 2001
Posts: 85
I understand that, but HOW does an inexperienced JSP programmer implement something like that? I think it's returning something, the page says "processName@90f323", or something like that.
[This message has been edited by kevin schmidt (edited August 30, 2001).]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: calling java files from jsp page
 
Similar Threads
Servlet runs, but doesn't do anything
file upload works on windows, doesn't on unix
Problem creating files from JSP
copying files from one folder to another
whats the Diff between getHibernateTemplate().getSessionFactory().getCurrentSession() and getSession