Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unable to import the java file into the JSP file.

 
Narasimha Rao B.
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am working on Bee Weblogic Server 5.1. In one of the JSP file, i am trying to import the java file ("HelloWorld.java"), using the below syntax,
<%@ page import="HelloWorld" %>
JSP file is located at -- <<instal_dir>>/myserver/public_html
and
Java file, "HelloWorld.java" is located at -- <<instal_dir>>/myserver/servletclasses.
I am getting the below error in browser when loading the JSP file,
---------------------
D:\weblogic5.1c\myserver\classfiles\jsp_servlet\_jsp\__man.java:16: '.' expected
probably occurred due to an error in /jsp/man.jsp line 4:
<%@ page import="HelloWorld" %>
--------------------------------
Please help me in solving the above problem.
One more thing, I am getting the error, when creating the instance of any java class, using the below syntax,
---------------------
<%=new SomeJavaFile()%>
------------------------
By the way, the Java file, "SomeJavaFile.java" is located -- <<instal_dir>>/myserver/servletclasses.
But when, i am able to instantiate the frame work classes and the below coding is working fine and i am getting the proper output of the below code,
--------------------
<%=new Date()%>
----------------------------
It seems, JSP file is failing to locate the custom java classes.
Please do help me in solving the problem. I tried a lot to solve, but couldn't.
Thanks in Advance,
Narasimha.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65114
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to the Weblogic forum.
bear
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"import" isn't intended to work with .java files; it imports compiled classes to make them available to the Java code in the JSP. Your HelloWorld and other .java files need to be compiled, then the .class files should be in the classes directory. Finally, if these classes aren't in a named package -- i.e., if there's no "package" statement in the .java file -- then the "import" statement isn't needed anyway, as long as the .class files are available.
 
Narasimha Rao B.
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Earn,
Thanks a lot for ur help. Here the problem is my class file "HelloWorld.class" is available at <<instal_dir>>/myserver/classfiles.
Still i am getting the same error.
Below i am giving ur statements,
"Your HelloWorld and other .java files need to be compiled, then the .class files should be in the classes directory."
Can you tell me what is the classes directory means? Is it <<instal_dir>>/myserver/classfiles or someother directory. I am not having any directory called as "classes".
Please help me out in solving this problem.
By the way, i am able to import files for jdk lib dir, i.e., below code is working fine,
<%@ page import="java.util.Calendar" %>
Thanks in Advance.
Narasimha.
[ October 04, 2003: Message edited by: narasimha rao bandlamudi ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic