You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jeremy Linzer <jl...@alabanza.com> on 2000/07/07 19:30:29 UTC

setting up Tomcat for my own work

I am new to Linux(Red Hat 6.1), JSP, Java etc.. I installed the jdk1.2.2
(which runs fine) and Tomcat 3.1 (which runs fine with their examples)
My problems start when I want to write my own JSPs and Beans. I don't
know where to put what (into which directories) and which, if any,
environment settings I need. I was able to get a JSP page working when
it contained just HTML or scripting tags by putting it in a subdirectory
of jakarta-tomcat/webapps/examples/jsp/. The problems started with
beans. I used the HelloBean example from the book  Web Development with
Java Server Pages by Duane Fields and Mark Kolb (p.25) and put the jsp
file in the directory with my other JSPs and the bean I put in
/usr/local/jakarta-tomcat/webapps/examples/WEB-INF/classes/ where the
Tomcat user's guide (I beleive) says to put it - and it didn't work. I
then put created a series of sub directories under  WEB-INF/classes/
which were com/taglib/wdjsp/fundamentals/ and put my bean there and it
worked.

I would like to know

1. Is there a way I could avoid burying my bean so far down? I assume I
needed to create all those sub directories because of the package line
at the beg. of the HelloBean (package com.taglib.wdjsp.fundamentals;).I
would like to put it even just into WEB-INF/classes/, if I can. I tried
getting rid of that line (and I took it out of my JSP useBean) and it
didn't work. I got
Error 500
Internal Servlet Error:

org.apache.jasper.JasperException: Unable to compile class for
JSP/usr/local/jakarta-tomcat/work/localhost_8080%2Fexamples/_0002fjsp_0002fjspdev_0002fHelloBeanTry_0002ejspHelloBeanTry_jsp_0.java:63:
Class jsp.jspdev.HelloBeanTry not found.
                HelloBeanTry hello = null;

Any suggestions?

2. Can I put the beans some other place then in WEB-INF/classes/? If so,
how? I tried setting up a new Context (path and docBase) in the
ContextManager of server.xml for my JSPs and beans but that didn't work.
What can I do? Do I need to edit the CLASSPATH at all for the JSPs and
beans? Eventually I would like to set up an application but I am very
confused how to get there with all the things I need to configure.

3. Even if my beans have to be were they are can I put my JSPs somewhere
else?

4. An unrelated issue- you say on page 26 of your book (as you can see I
haven't gotten to far yet) that the setProperty found a parameter with
same name as one of the Beans properties(i.e name) (paragraph starting
with "Suppose,"). Do the Bean property and the parameter have to have
the same name or could they be different but it would be clear from the
setProperty which property you want to set from which parameter?

6. Do I have to compile my Beans beforehand or will it happen when they
are needed?

Thank you in advance for any and all suggestions. I really appreciate it
(them).

Jeremy

Here is my HelloBean.java
package com.taglib.wdjsp.fundamentals;
public class HelloBean implements java.io.Serializable {
  String name;

  public HelloBean() {
    this.name = "World";
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }
}

Here is my HelloBean.jsp
<HTML>
<BODY>
<jsp:useBean id="hello"
class="com.taglib.wdjsp.fundamentals.HelloBean"/>
<jsp:setProperty name="hello" property="name" param="name"/>
Hello, <jsp:getProperty name="hello" property="name"/>
</Body>
</HTML>


RE: HELP: Stack trace in browser - how?

Posted by "Rob S." <rs...@home.com>.
> I'm not sure where they were disabled either, but I know it was done
> for security reasons.  Stack traces reveal information about your
> internal config that may be exploitable.  Instead, you need to check
> the logs.
>
> Personally, I think this should be an option -- it's really convenient
> to see errors on the page, and as long as you can disable it for a
> live site -- but I haven't felt strongly enough about it to write a
> patch :-)

I never knew it would happen, because w/JServ you always "tail -f"'ed the
log and it was kind of a pain.

The first thing I thought when the stack popped up was "COOL!" and the
second thing I thought was, "yeah but wait a minute..." =)  I immediately
assumed there was an option, but because I won't be going live for so long,
I put off looking into it.

Where would this go?  In server.xml?

- r


Re: HELP: Stack trace in browser - how?

Posted by Alex Chaffee <gu...@edamame.stinky.com>.
I'm not sure where they were disabled either, but I know it was done
for security reasons.  Stack traces reveal information about your
internal config that may be exploitable.  Instead, you need to check
the logs.

Personally, I think this should be an option -- it's really convenient
to see errors on the page, and as long as you can disable it for a
live site -- but I haven't felt strongly enough about it to write a
patch :-)

 - Alex

On Fri, Jul 07, 2000 at 01:28:55PM -0700, Rob S. wrote:
> Hi all,
> 
> FAQ-o-matic is down =(  Since moving from 3.1 -> 3.2dev, I've lost stack
> traces in the browser.  I couldn't see where this was en/disabled.  Any
> tips?
> 
> - r

-- 
Alex Chaffee                       mailto:alex@jguru.com
jGuru - Java News and FAQs         http://www.jguru.com/alex/
Creator of Gamelan                 http://www.gamelan.com/
Founder of Purple Technology       http://www.purpletech.com/
Curator of Stinky Art Collective   http://www.stinky.com/

RE: HELP: Stack trace in browser - how?

Posted by "Rob S." <rs...@home.com>.
Eric,

Actually, I was thinking more about Tomcat's own exceptions, like during JSP
compilation?

Sorry I wasn't more clear in my original question.  Thanks very much for the
reply ;)

- r

> -----Original Message-----
> From: Eric H. [mailto:eharashe@usc.edu]
> Sent: July 7, 2000 1:35 PM
> To: tomcat-user@jakarta.apache.org
> Subject: Re: HELP: Stack trace in browser - how?
>
>
> To print a stacktrace from a jsp, I'm using:
>
> Stack Trace:<BR><CODE>
> <%
> CharArrayWriter c=new CharArrayWriter();
> PrintWriter e=new PrintWriter(c);
> exception.printStackTrace(e);
> e.flush();
> %>
> <%=c.toString()%>
> </CODE>
>
> Note that exception.printStackTrace() prints to standard error... probably
> not to your web page unless you found a way to redirect it...
>
> On Fri, 7 Jul 2000, Rob S. wrote:
>
> > Hi all,
> >
> > FAQ-o-matic is down =(  Since moving from 3.1 -> 3.2dev, I've lost stack
> > traces in the browser.  I couldn't see where this was en/disabled.  Any
> > tips?
> >
> > - r
> >
> >
> >
>
> -Eric Harashevsky
>


Re: HELP: Stack trace in browser - how?

Posted by "Eric H." <eh...@usc.edu>.
To print a stacktrace from a jsp, I'm using:

Stack Trace:<BR><CODE>
<%
CharArrayWriter c=new CharArrayWriter();
PrintWriter e=new PrintWriter(c);
exception.printStackTrace(e); 
e.flush();
%>
<%=c.toString()%>
</CODE>

Note that exception.printStackTrace() prints to standard error... probably
not to your web page unless you found a way to redirect it...

On Fri, 7 Jul 2000, Rob S. wrote:

> Hi all,
> 
> FAQ-o-matic is down =(  Since moving from 3.1 -> 3.2dev, I've lost stack
> traces in the browser.  I couldn't see where this was en/disabled.  Any
> tips?
> 
> - r
> 
> 
> 

-Eric Harashevsky


HELP: Stack trace in browser - how?

Posted by "Rob S." <rs...@home.com>.
Hi all,

FAQ-o-matic is down =(  Since moving from 3.1 -> 3.2dev, I've lost stack
traces in the browser.  I couldn't see where this was en/disabled.  Any
tips?

- r