- This topic has 4 replies, 3 voices, and was last updated 19 years, 7 months ago by
Scott Anderson.
-
AuthorPosts
-
janmartinMemberHi all,
istarted with Eclipse and myEclipseIDE this weekend.
I am really interested, but will become a customer only once this works.Please help.
What i did:
I am at Kanotix Linux version 2005-03, a Debian SID.installed
– java 1.4.2: j2sdk-1_4_2_08-linux-i586.bin
activate it using “alternatives” command.
– mozilla to enable preview: mozilla-1.6-xft-gtk2-pc-linux.tar.bz2
– eclipse: eclipse-SDK-3.0.2-linux-gtk.zip
– myeclipseide manually: myeclipse_030804.zip
– jakarta-tomcat-5.5.9.tar.gz
– jakarta-tomcat-5.5.9-compat.tar.gz (needed for java 1.4.2)Then I did the helloworld example fromt he tutorial, and run into problems.
There are always 2 problems with the code:cannot resolve symbol: symbol : class HelloWorld helloWorld.jsp
cannot resolve symbol: symbol : class HelloWorldBean helloWorld.jspThe files:
HelloWorldBean.java<%@ page language="java" import="java.util.*" %> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>My JSP 'helloWorld.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> <% HelloWorld hw = new HelloWorldBean(); out.println("massage = " + hw.helloworld()); %> </body> </html>
helloWorld.jsp
<%@ page language="java" import="java.util.*" %> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>My JSP 'helloWorld.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> <% HelloWorld hw = new HelloWorldBean(); out.println("massage = " + hw.helloworld()); %> </body> </html>
Start tomcat in eclipse.
Preview looks like this:
<% __myeclipse-0__ %> <% __myeclipse-1__ %> <% __myeclipse-3__ %>
Deploy, call
localhost:8080/HelloWorld/helloWorld.jsp
get an error message:HTTP Status 500 - type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception org.apache.jasper.JasperException: Unable to compile class for JSP An error occurred at line: 27 in the jsp file: /helloWorld.jsp Generated servlet error: HelloWorld cannot be resolved or is not a type An error occurred at line: 27 in the jsp file: /helloWorld.jsp Generated servlet error: HelloWorldBean cannot be resolved or is not a type org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84) org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328) org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:397) org.apache.jasper.compiler.Compiler.compile(Compiler.java:288) org.apache.jasper.compiler.Compiler.compile(Compiler.java:267) org.apache.jasper.compiler.Compiler.compile(Compiler.java:255) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:556) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:293) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) note The full stack trace of the root cause is available in the Apache Tomcat/5.5.9 logs. Apache Tomcat/5.5.9
Any ideas?
Thank you,
JanP.S.:
“Preview” does not work for me in the forum.
Scott AndersonParticipantJan,
You need to add imports for the HelloWorld and HelloWorldBean classes in your JSP. Without imports, the compiler doesn’t know where to look for the classes, just like in regular java code.
As for the Preview, this is a GTK library version problem and I’ve asked a “Linux guy” to weigh in on that.
GregMemberJan,
For the Preview question, see my respose in this thread:
http://www.myeclipseide.com/PNphpBB2+file-viewtopic-t-7657.html
janmartinMemberThanks,
it now works:
HelloWorld.java
package com.genuitec.test; public class HelloWorld { public String helloWorld() { return "hello world"; } }
helloWorld.jsp
<%@ page import="com.genuitec.test.*" %> <%@ page language="java" %> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>My JSP 'helloWorld.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> <% HelloWorld hw = new HelloWorld(); out.println("message = " + hw.helloWorld()); %> </body> </html>
P.S.:
The preview function still doesn’t work in this forum.
Scott AndersonParticipantClosing, since preview question is taken up in another thread.
-
AuthorPosts