Re: relative path to real one

2001-07-16 Thread Aditya Anand

Use ServletContext.getRealPath("xyz"); to do this.
This assumes that xyz is a resource in your context
root
--- Jaume Pausas <[EMAIL PROTECTED]> wrote:
> Hi!
> 
> Is it possible to translate a relative path to its
> absolute one in the web
> pages under Tomcat 4.0b5?
> 
> So if I have a context named "mycontext" and some
> day I decided to change
> its name to "myothercontext" how can I manage to
> perform any changes?
> 
> Thanks,
> JPausas
> 
> 
> 
> 
> 
>
___
> ¡Tienes cuentas de e-mail GRATIS en Excite España!
> A tu disposición en http://correo.excite.es 
> 


__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



read-only initial context

2001-07-16 Thread Aditya Anand

Hi i'm trying to bind an object to "java:comp/env"
using initial context and i get the attached exception
message. I am using tomcat-4.0-b5, Clearly the message
says the context is read-only, how do i change this.
The same code executes fine over resin and jrun.

TIA

Aditya
---> The Exception <---
javax.naming.NamingException: Context is read only
at
org.apache.naming.NamingContext.checkWritable(NamingContext.java:935)
at
org.apache.naming.NamingContext.bind(NamingContext.java:863)
at
org.apache.naming.NamingContext.rebind(NamingContext.java:249)
at
org.apache.naming.NamingContext.rebind(NamingContext.java:264)
at
org.apache.naming.SelectorContext.rebind(SelectorContext.java:253)
at
javax.naming.InitialContext.rebind(InitialContext.java:366)
at
com.casewerks.web.controller.Controller.init(Controller.java:34)
at
javax.servlet.GenericServlet.init(GenericServlet.java:258)
at
org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:833)
at
org.apache.catalina.core.StandardContext.start(StandardContext.java:3277)
at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:785)
at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:413)
at
org.apache.catalina.core.StandardHost.install(StandardHost.java:641)
at
org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:300)
at
org.apache.catalina.startup.HostConfig.start(HostConfig.java:389)
at
org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:232)
at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:155)
at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1131)
at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1123)
at
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:278)
at
org.apache.catalina.core.StandardService.start(StandardService.java:353)
at
org.apache.catalina.core.StandardServer.start(StandardServer.java:458)
at
org.apache.catalina.startup.Catalina.start(Catalina.java:725)
at
org.apache.catalina.startup.Catalina.execute(Catalina.java:647)
at
org.apache.catalina.startup.Catalina.process(Catalina.java:177)
at java.lang.reflect.Method.invoke(Native
Method)
at 
org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:196)


__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



what's wrong here?

2001-07-17 Thread Aditya Anand

Hi what is wrong with this code?

ic = new InitialContext();
Object myObj = new MyObject();
ic.rebind("java:comp/env/my_object", myObj);
// I even tried "java:/comp/env/my_obj"
ic.close();

I get a NamingException saying the context is
readonly.
I am using Tomcat 4.0 beta5 on NT / JVM 1.3.0_02

any suggestion?

Adi


__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



Re: JSP's not finding classes in WEB-INF

2001-07-18 Thread Aditya Anand

> Greetings!
> 
> Ok - running Tomcat 3.2 on SunOS 2.7, with Java 1.2.
>  
> 
> I have a working application with servlets and JSP
> pages running under
> Tomcat 3.1.  I'm trying to port it to 3.2.
> 
> However, every time I hit a JSP page, it gives a 500
> error about how it
> cannot find classes to compile.  Those classes are
> located in the WEB-INF
> directory, under the /classes folder.  

I assume these are your bean classes. These should be
put under the WEB-INF/lib directory rather than the
classes directory. The classes directory is ment only
for un-jarred servlet classes that have been declared
in the web.xml file.

> The classpath does *not* contain the WEB-INF/classes
> directory.
you donot have to specify WEB-INF/classes in the
system classpath
 
> If I hard-code the WEB-INF/classes directory into
> the classpath, they
> work.  However, I do not want to do this.  
> 
> What is the problem, and how can I resolve it?
> 
> I have tried settiing the environment variables
> TOMCAT_HOME and JAVA_HOME,
> and moving tools.jar into TOMCAT_HOME/lib.
Put any servlet jars, beans, and required
non-statndard libraries under the lib folder (like
log4J, or xalan)

cheers
Adi


__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



Re: JSP's not finding classes in WEB-INF

2001-07-18 Thread Aditya Anand

this seems stupid but did u restart the server!...
also you do have the servlets defined in
web.xml..right?

I use 4.0 b-5, and I haven't come across this problem,

My servlets and Beans are in separate jar files under
WEB-INF/lib, which also contains other jars need,
Ihave never touched the classpath setup by Tomcat, and
it orks just fine

Can I have a peek at the logs?


--- Will England <[EMAIL PROTECTED]> wrote:
> On Wed, 18 Jul 2001, Aditya Anand wrote:
> 
> > > However, every time I hit a JSP page, it gives a
> 500
> > > error about how it
> > > cannot find classes to compile.  Those classes
> are
> > > located in the WEB-INF
> > > directory, under the /classes folder.  
> > 
> > I assume these are your bean classes. These should
> be
> > put under the WEB-INF/lib directory rather than
> the
> > classes directory. The classes directory is ment
> only
> > for un-jarred servlet classes that have been
> declared
> > in the web.xml file.
> 
> Actually, just to make things interesting, those
> *are* servlet
> classes.  We have both servlets and JSP's that use
> library classes for
> various things.  Currently, they live in
> WEB-INF/classes.  One of these
> years we'll get things sorted out a bit better.
> 
> > Put any servlet jars, beans, and required
> > non-statndard libraries under the lib folder (like
> > log4J, or xalan)
> 
> Ok, so I created a jar file with the servlet classes
> and library classes
> in it and moved it to WEB-INF/lib.
> 
> Didn't work.
> 
> I cannot put this .jar file in TOMCAT_HOME/lib --
> each context / virtual
> host will have slightly different bits in the
> servlets.
> 
> Will
> 


__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



RE: The 4.0b5 doesn't recognize a servlet class

2001-07-18 Thread Aditya Anand

hmm... did you recompile the classes using the tomcat
lib jars?
--- Vernon Wu <[EMAIL PROTECTED]> wrote:



Hi, 
 
As you suggested, I moved the j2ee.jar from the
web-inf\lib to common\lib. And then I restarted the
Tomcat 4.0b5. Here is what I got:
Catalina.start: LifecycleException:  start:
: 
java.lang.NoSuchMethodErrorLifecycleException: 
start: : 
java.lang.NoSuchMethodError   
at
org.apache.catalina.loader.StandardLoader.start(StandardLoader.java:649)   
at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1100)
    at
org.apache.catalina.core.StandardContext.start(StandardContext.java:3189)   
at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1123)
    at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1123)
    at
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:278)   
at
org.apache.catalina.core.StandardService.start(StandardService.java:353)   
at
org.apache.catalina.core.StandardServer.start(StandardServer.java:458)   
at
org.apache.catalina.startup.Catalina.start(Catalina.java:725)   
at
org.apache.catalina.startup.Catalina.execute(Catalina.java:647)   
at
org.apache.catalina.startup.Catalina.process(Catalina.java:177)   
at java.lang.reflect.Method.invoke(Native
Method)   
at
org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:196)-
Root Cause
-java.lang.NoSuchMethodError   
at
org.apache.catalina.loader.StandardLoader.start(StandardLoader.java:627)   
at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1100)
    at
org.apache.catalina.core.StandardContext.start(StandardContext.java:3189)   
at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1123)
    at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1123)
    at
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:278)   
at
org.apache.catalina.core.StandardService.start(StandardService.java:353)   
at
org.apache.catalina.core.StandardServer.start(StandardServer.java:458)   
at
org.apache.catalina.startup.Catalina.start(Catalina.java:725)   
at
org.apache.catalina.startup.Catalina.execute(Catalina.java:647)   
at
org.apache.catalina.startup.Catalina.process(Catalina.java:177)   
at java.lang.reflect.Method.invoke(Native
Method)   
at
org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:196)
 
If I don't relocate the j2ee.jar file, when I try
to open up the main page which doesn't call any
servlet instance. What I get is the followings:
Exception
Report:javax.servlet.ServletException: Class
org.apache.jasper.servlet.JspServlet is not a
Servlet...Root
Cause:java.lang.ClassCastException:
org.apache.jasper.servlet.JspServlet...Please
advise what steps I shall
take Thanks.

Original Message Follows 
From: Wells Tiedeman
<[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED] 
To: "'[EMAIL PROTECTED]'"
<[EMAIL PROTECTED]>
Subject: RE: The 4.0b5 doesn't recognize a
servlet class 
Date: Tue, 17 Jul 2001 16:06:10 -0400 
MIME-Version: 1.0 
Received: from [64.208.42.41] by
hotmail.com (3.2) with ESMTP id
MHotMailBD1DE6CE00214004389F40D02A290FE90; Tue, 17 Jul
2001 13:10:55 -0700 
Received: (qmail 38493 invoked by uid 500);
17 Jul 2001 20:10:46 - 
Received: (qmail 38486 invoked from
network); 17 Jul 2001 20:10:45 - 
Received: from
salesvision-gw.youcentric.com (HELO
yc?exchange.yc?exchange.salesvision.com) (12.19.52.2)
by h31.sny.collab.net with SMTP; 17 Jul 2001 20:10:45
- 
Received: by
yc_exchange.yc_exchange.salesvision.com with Internet
Mail Service (5.5.2653.19)id <3XZSJXH3>; Tue, 17
Jul 2001 16:06:11 -0400 
From tomcat-user-return-41410-vwu0 Tue, 17
Jul 2001 13:11:00 -0700 
Mailing-List: contact
[EMAIL PROTECTED]; run by ezmlm 
Precedence: bulk 
list-help: 
list-unsubscribe:

list-post:

Delivered-To: mailing list
[EMAIL PROTECTED] 
Message-ID:
<[EMAIL PROTECTED]>

X-Mailer: Internet Mail Service
(5.5.2653.19) 
X-Spam-Rating: h31.sny.collab.net 1.6.2
0/1000/N 

Any of the jars/classes containing the
packages java.*, com.sun.*, javax.*, 
etc. If any of these are included in your
/WEB-INF/lib directory the class 
loaders get confused. 

-Wells 

-Original Message- 
From: Vernon Wu [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, July 17, 2001 3:49 PM 
To: [EMAIL PROTECTED] 
Subject: The 4.0b5 doesn't recognize a
servlet class 







Hi, Wells, 



Thanks for your response. 



It took me awhile trying to figure how the
CLASSPATH relates with the 
problem. I build up the JSP application
using Tomcat 3.x with the standard 
procedure. Nothing inside the project is
set up in the CLASSPATH. I don't 
know what you means by "all j2ee platform
classes". Are the classes used 
j2ee APIs? 



Thx. 



Vernon 



Original Message Follows 
From: Wells Tiedeman 
Reply-To: [EMAIL PROTECTED] 
To: "'[EMAIL PROTECTED]'" 
Subj

Re: Tomcat: subject

2001-07-18 Thread Aditya Anand

why don't you just setup a filter based on the 'to'
address!
--- "Li, Jerry" <[EMAIL PROTECTED]> wrote:
> Hi, All:
> 
> We have been flooded by emails from the mailing
> lists of CVS, apache,
> tomcat, and so on. All of them come into our inbox,
> it is very tough to
> separate them. If you send emails with "Tomcat" in
> the subject, we could
> easily group them and redirect them into a dedicated
> folder. For example,
> Windows user may create a rule in outlook to
> redirect all emails with Tomcat
> in the subject to a folder called Tomcat.
> 
> thanks,
> 
> Jerry
> 
> 


__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



RE: Generate Excel File

2001-07-19 Thread Aditya Anand

Actually using tabs is like running from the problem,
it the data contains a tab, then it would mess things
up again...you'll need to do a litle encoding for
this...

if the data is like..
Col1Col2col3
data1   data"2  data,3
data"4   data,5  data6
data,7   data8  data"9

then you output as

"col1","col2","col3"
"data1","data""2","data,3"
"data""4","data,5","data6"
"data,7","data8","data""9"

note here that these should be no space between the
deliminator comma and the enclosing double-quote. If
there is one, excel will presume the data not encoded
and treat the enclosing double quotes as part of the
element breaking on the first comma it hits...this is
one reason i donot use tabs, you could as well switch
to tabs instead of commas as long as you use the
double quotes, but tabs make it visually harder to
notice if spaces were pumped after the deliminator and
before the enclosing dbl-quotes... i use the following
code to accomplish this...


public class CSVEncoder{

private static final char DOUBLE_QUOTE = '"';
private static final String COMMA_DOUBLE_QUOTE =
",\"";

/**
 * This method encodes a String array into a row for
a CSV file
 * ex:
 * if you were to pass in the following array
 *  String[] values = {"data1", "data\"2", "data3"};
 *
 * using a syntax like..
 *  String encodedValus = CSVEncoder.encode(values);
 *
 * you'd get...
 *  "\"data1\",\"data\"\"2\",\"data,3\""
 *
 * appearing as...
 *  "data1","data""2","data,3"
 * in the data stream
 **/
public static String encode(String[] columns){

if(columns.length < 1)
return null;

StringBuffer encoded = new StringBuffer();

// encode the firstElement
encoded.append(DOUBLE_QUOTE);
encoded.append(encode(columns[0]));
encoded.append(DOUBLE_QUOTE);

//encode the rest of'em
int maxLoop = columns.length;
for (int loop = 1; loop < maxLoop; loop++){

encoded.append(COMMA_DOUBLE_QUOTE);
encoded.append(encode(columns[loop]));
encoded.append(DOUBLE_QUOTE);
}
return encoded.toString();
}

/**
 * encodes a given string into a CSV safe format
 * ex:
 * if you were to pass a String...
 *  String value = "6\"3\', 190.5 cm"; //6"3', 190.5
cm
 *
 * using a syntax like...
 *  String encodedValue = CSVEncoder.encode(value);
 *
 * you'd get...
 *  "6""3', 190.5 cm"
 *
 * which would look like...
 *  6""3', 190.5 cm
 * in the data stream
 **/
public static String encode(String s){

StringBuffer encoded = new StringBuffer();

int maxLoop = s.length();
for(int loop = 0; loop < maxLoop; loop++){

char theChar = encoded.charAt(loop);

//if the current char is a dbl-quote, stuff another
dbl-quote into the buffer
if(theChar == DOUBLE_QUOTE)
encoded.append(DOUBLE_QUOTE);

encoded.append(theChar);
}

return encoded.toString();
}
}
--- Erin Lester <[EMAIL PROTECTED]>
wrote:
> Actually that's how it was formatted.  I tried what
> someone else
> suggested, using tabs instead of commas, and that
> worked.
> 
> Thanks,
> Erin
> 
> On Thu, 19 Jul 2001, Paul Kofon wrote:
> 
> ><>Hi,
> ><>I've never done what you'd like to do. But if I
> remember correctly, the CSV 
> ><>text below will display correctly in Excel:
> ><>
> ><>Item,Price
> ><>Doll,30
> ><>GameBoy,200
> ><>
> ><>You'd have two rows and two columns (with headers
> Item and Price) of data. 
> ><>If the CSV data you're feeding Excel is not
> formatted like this, then 
> ><>chances are that you'd get wrong results - that
> explains why your single row 
> ><>of data isn't showing up correctly.
> ><>
> ><>Regards,
> ><>
> ><>Paul
> ><>
> ><>>From: William Kaufman <[EMAIL PROTECTED]>
> ><>>Reply-To: [EMAIL PROTECTED]
> ><>>To: "'[EMAIL PROTECTED]'"
> <[EMAIL PROTECTED]>
> ><>>Subject: RE: Generate Excel File
> ><>>Date: Wed, 18 Jul 2001 17:58:12 -0700
> ><>>
> ><>>We've got it working exactly as you say, but
> only if the data is delimited
> ><>>with _tabs_, not _commas_.
> ><>>
> ><>> -- Bill
> K.
> ><>>
> ><>> > -Original Message-
> ><>> > From: Erin Lester
> [mailto:[EMAIL PROTECTED]]
> ><>> > Sent: Wednesday, July 18, 2001 2:21 PM
> ><>> > To: [EMAIL PROTECTED]
> ><>> 

Re: Tomcat / J2EE - JNDI Help!!!

2001-08-13 Thread Aditya Anand

Okie... just pondering if tomcat provides a directory
service standalone i tried binding regular
serializable java objects to the  directory and get a
security exception saying the context is read-only!

--- Sophie <[EMAIL PROTECTED]> wrote:
> Hi,
> 
> I am not working with your configuration, but I was
> wondering whether you had set your
> JNDI parameters correctly. For the tomcat server
> there is a need to update tomcat.sh
> (or tomcat.bat) and also your EJB server needs to
> have the correct address. Please let
> me know if the statements I am using would be useful
> for you.
> Sophie
> 
> Papo Napolitano schreef:
> 
> > Hi all!
> >
> > I't trying to make a webapp with JSP and Session
> Beans.
> > I've written my own EJB called usermanager and it
> was tested in my machine
> > (localhost). I've made the deploy with deploytool
> from sun and works fine.
> >
> > Now, I want to install it on my server (Tomcat
> 4.06b / J2EE). I made the
> > deploy with the and application but I don't know
> how must I do to bound this
> > EJB to a JNDI name to use it from JSP.
> >
> > This is my JSP code:
> >
> > <%
> > InitialContext ctx = new InitialContext();
> > Object objref = ctx.lookup("usermanager");
> > UserManagerHome homeuser =
> >
> (UserManagerHome)PortableRemoteObject.narrow(objref,
> UserManagerHome.class);
> > UserManager UsrMgr = homeuser.create();
> > .
> > .
> > %>
> >
> > When I run it from my browser I get the following
> error:
> >
> > javax.servlet.ServletException: Name usermanager
> is not bound in this
> > Context
> > at
> >
>
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImp
> > l.java:452)
> > at
> >
>
org.apache.jsp._0002fuserfunc_jsp._jspService(_0002fuserfunc_jsp.java:121)
> > at
>
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
> > at
>
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> > at
> >
>
org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.ja
> > va:200)
> > at
>
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:379)
> > at
>
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:456)
> > at
>
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> > at
> >
>
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
> > FilterChain.java:247)
> > at
> >
>
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
> > ain.java:193)
> > at
> >
>
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
> > va:243)
> > at
> >
>
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> > 66)
> > at
> >
>
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
> > at
>
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> > at
> >
>
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
> > va:219)
> > at
> >
>
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> > 66)
> > at
> >
>
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
> > at
>
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> > at
> >
>
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2251)
> > at
> >
>
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164
> > )
> > at
> >
>
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> > 66)
> > at
> >
>
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:446)
> > at
> >
>
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> > 64)
> > at
> >
>
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
> > at
>
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> > at
> >
>
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
> > :163)
> > at
> >
>
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> > 66)
> > at
> >
>
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
> > at
>
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> > at
> >
>
org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:
> > 984)
> > at
> >
>
org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1074
> > )
> > at java.lang.Thread.run(Thread.java:484)
> >
> > Cheers,
> > Papo
> 


__
Do You Yahoo!?
Send instant messages & get email alerts with Yahoo! Messenger.
http://im.yahoo.com/