• Post Reply Bookmark Topic Watch Topic
  • New Topic

Calling java classes from jsp  RSS feed

 
Mathangi Shankar
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bear,

I am trying to deploy jsp and java in Websphere. I have followed the same rules as you have said to call a java class from a jsp.

Where should I put the class file? What is the structure I need to follow?

Because I am getting the following error in the jsp.


Class com.test.pack.DBConnectionManager not found in import.
import com.test.pack.DBConnectionManager;
^
1 error


This is my jsp:

<%@ page language="java"%>
<%@ page import="com.test.pack.DBConnectionManager"%>
<html>
<head>
<h1>Welcome to the test connection</h1>
<%
DBConnectionManager obj = new DBConnectionManager();
try
{
out.println("inside try");
obj.getConnection();
out.println("Got the conn");
}
catch(Exception e)
{
System.err.println("Could not connect" + e);
}

%>

</head>
</html>
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Classes specific to your web app should be placed in a package hierarchy rooted at WEB-INF/classes.
 
Mathangi Shankar
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I put my class file in a package com.test.pack which is under WEB-INF. It still did not work.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you put it in WEB-INF/classes/com/test/pack/?
 
Mathangi Shankar
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, Please let me know how should I create a .war file to deploy in websphere containing my jsp and the java file which I use in the jsp.


I have created the .war using the AAT as well as I tried in the command promt.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!