Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-16-2009, 08:07 PM   PM User | #1
jayeshhalarnkar
New to the CF scene

 
Join Date: Feb 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
jayeshhalarnkar is an unknown quantity at this point
How to call a Java class from a JSP

Hello every body

I am learning JSP from a e-book "Teach Yourself JSP 2.0 with Apache Tomcat in 24 Hours (Sams, 2003)". here actually an example is given where we have to call a class from a JSP by importing it.

here is the code
ReloadTest.jsp
<%@ page language="java" import="examples.*" %>
<html>
<body>
The message is: <%= ReloadedClass.getMessage() %>
</body>
</html>

ReloadedClass.java
package examples;

public class ReloadedClass
{
public static String getMessage()
{
return "This is the original message";
}
}

Can some one please help me i actually dont know where to place the ReloadedClass.class file. And one more thing i have not actually used the package named 'examples'. i am using the Apache Tomcat Server so please guide me where should i place the .class file and under which folder.
right now i am placing the class file under "\Tomcat\webapps\examples\WEB-INF\classes\" the default place for placing class files as that of servlets
jayeshhalarnkar is offline   Reply With Quote
Old 02-17-2009, 05:06 AM   PM User | #2
servlet
Regular Coder

 
Join Date: Jan 2009
Location: india
Posts: 145
Thanks: 0
Thanked 5 Times in 5 Posts
servlet is an unknown quantity at this point
It's okey to put the ReloadedClass class file in WEB-INF/classes folder.

Quote:
one more thing i have not actually used the package named 'examples'
Then remove import="examples.*" you don't need it.

Look at J2EE web application directory structure
servlet is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:59 AM.


Advertisement
Log in to turn off these ads.