Crace Selvage

Greenhorn
+ Follow
since Jan 14, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Crace Selvage

Ben, thanks for pointing that out. I have modified the import statement to
import com.example.model.*;

However, it is still not compiling. Here is the output I receive...

web>javac BeerSelect.java
BeerSelect.java:3: package com.example.model does not exist
import com.example.model.*;
^
BeerSelect.java:4: package javax.servlet does not exist
import javax.servlet.*;
^
BeerSelect.java:5: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
BeerSelect.java:10: cannot find symbol
symbol : class HttpServletRequest
location: class com.example.web.BeerSelect
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
^
BeerSelect.java:10: cannot find symbol
symbol : class HttpServletResponse
location: class com.example.web.BeerSelect
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
^
BeerSelect.java:10: cannot find symbol
symbol : class ServletException
location: class com.example.web.BeerSelect
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{

Thanks for looking,
Crace
17 years ago
Thanks for the quick response. My CLASSPATH is now set to this...

.;JAVA_HOME\bin;C:\Program Files\Apache Tomcat\apache-tomcat-5.5.17\common\lib\servlet-api.jar;

However, I am getting the same messages I stated earlier. I have also tried adding just the path (the path up to the lib folder). Anyone see what I am doing wrong?

Thanks,
Crace
17 years ago
Hi all, the search function on here is down, so I apologize for posting what I'm sure is a repeat...

I'm working on the Ch3 MVC tutorial in Headfirst Servlets & JSP. I have created my folder structure in Tomcat as this... webapps > Beer > WEB-INF > classes > com > example. The example directory stores the model and web directories. I have two java files in this project.



My first file, BeerExpert.java compiles fine. When I try compiling the second file, BeerSelect.java, I receive the following output...

webapps\Beer\WEB-INF\classes\com\example\web>javac BeerSelect.java
BeerSelect.java:3: cannot find symbol
symbol : class model
location: package com.example
import com.example.model;
^
BeerSelect.java:4: package javax.servlet does not exist
import javax.servlet.*;
^
BeerSelect.java:5: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
BeerSelect.java:10: cannot find symbol
symbol : class HttpServletRequest
location: class com.example.web.BeerSelect
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
^
BeerSelect.java:10: cannot find symbol
symbol : class HttpServletResponse
location: class com.example.web.BeerSelect
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
^
BeerSelect.java:10: cannot find symbol
symbol : class ServletException
location: class com.example.web.BeerSelect
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{



I am running j2se 1.6 and my classpath seems to be fine, as I am able to compile in command line. But I can't figure why my imports aren't working. Do I need to install j2ee, as well? And if so, what do I need to add to my classpath?

Thanks for your help,
Crace
[ January 07, 2007: Message edited by: Ben Souther ]
17 years ago
Yeah, the finally block executes. Always. Unless the jvm is killed off or a System.exit() is called.
17 years ago
Wrapper classes are a way of manipulating the values stored in a primitive data type, and then treating those values as if they were an object. All of the Wrapper classes have methods that interact with each particular primitive data type.
17 years ago
Once you perform any operation on an int, or anything larger, the smaller data type is promoted. Bytes are slightly different in this regard, as they are automatically treated as integers.
17 years ago
Once an exception is discovered your code will search for an appropriate catch block. Once it enters a catch block, it will never return back to the method, even if handled properly. Once the catch block is done flow will proceed to the finally block.


public class Test3{
public static void main(String args[]){
System.out.println(method());
}
public static int method(){
try{
throw new Exception();
}
catch(Exception e){
throw new Exception();
}
finally{
return 3;
}
}
}
17 years ago
I moved my project out of the ROOT folder. The absolute path is now C:\Program Files\apache-tomcat-5.5.17\webapps\pfl\WEB-INF\classes\com\craceonline\pfl\process

This solved the problem, as I am able to successfully import and instantiate other classes. Thanks for the help.
Crace
17 years ago
JSP
Hi all, I tried searching for a similar problem in the saloon, but could not find one.

I have created a Message class that has a getter/setter for the String message variable. This class was written in Eclipse in my project's src.entity package and using a test class I can successfully instantiate Message and set/get a message.

package entity;
public class Message {
private String message;
public Message(){}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}

The Message.class file is in the root folder for my project, pfl, in Apache Tomcat...Root/pfl/entity. When trying to use this class in a jsp I initially tried using an import page statement for the Message class at the top of my jsp.

<%@ page import="entity.Message" %> but this results in
Generated servlet error:Only a type can be imported. entity.Message resolves to a package

When trying to use a jsp tag
<jsp:useBean id="messageBean" class="entity.Message" /> I get back

org.apache.jasper.JasperException: /pfl/RegistrationConfirmation.jsp(49,0) The value for the useBean class attribute entity.Message is invalid.
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

Tomcat's log files didn't provide any more detailed information. Can anyone nudge me in the right direction???

Thanks,
Crace
17 years ago
JSP