jsp:usebean

2001-05-31 Thread Egidijus Drobavicius

Hi,
I've got one question:
I'd like to keep the constant string values in the single place to avoid the
mess. So I have class Constants.
let's say Constants have atrribute ATTR_MY_HANDLER="myHandler"
I use then code like this session.getAttribute(Constants.ATTR_MY_HANDLER).
This is OK
In jsp side i'd like to store this bean to session using jsp:usebean
directive.
But as i see the parser gets confused at this point if i write smth like
this
jsp:useBean id=Constants.ATTR_MY_HANDLER scope="session" class="MyHandler"
/
It insists that id value is of type String and is placed between "".
Is it possible to work around in nice way this situation or do I have to
place this attribute to the session manualy? I do hate using same attribute
in several places as it definetly leads to mistakes (i.e. I will not use
jsp:useBean id="myHandler" scope="session" class="MyHandler" /

Regards,

Egidijus Drobavicius
AB Vilniaus Bankas
http://www.vb.lt
tel. + 370 2 682706


Egidijus Drobavicius
AB Vilniaus Bankas
http://www.vb.lt
tel. + 370 2 682706




Re: jsp:usebean

2001-05-31 Thread Egidijus Drobavicius

Nope, but this is not actually var name. This is key for the hashtable.
And if i'd like to use SAME bean in two different places, i have to use SAME
key to retrieve the bean, i.e.
jsp:useBean id=myHandler scope=session class=MyHandler /
jsp:useBean id=myHandler1 scope=session class=MyHandler /
will create 2 objects and place them to session hash;
As long as the project is maintained by few people, i'd like to have these
var names defined to avoid mistyping and similar problems (you must admin,
that it is much easier to get compile time error saying that ATTR_MY_HANDLEW
is not defined than debug the code and find out that some person wrote
getAttribute (myHandlew))

Maybe i'm wrong, but this is my attitude :)
Regards,
Egidijus


- Original Message -
From: Edwin Martin [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, May 31, 2001 11:21 AM
Subject: Re: jsp:usebean


 Egidijus,

   I do hate using same attribute
 in several places as it definetly leads to mistakes (i.e. I will not use
 jsp:useBean id=myHandler scope=session class=MyHandler /

 You have a strange way of thinking, friend,

 You have to look at myHandler as a variable name.

 Do you store the name of a variable in a constant to clean up
 you code?

 Bye,
 Edwin Martin.






Re: Where's a servlet log?

2001-05-30 Thread Egidijus Drobavicius

It is $TOMCAT_HOME/logs/servlet.log. You can set this to any file by
modifying server.xml. This file is self explanatory
Note, that log file is started from scratch each time you restart the server
so you must take care of old log your self (i did this by modifying
tomcat.sh script.

Regards,
Egidijus

 Hi,
 When from a servlet i use the metthod HttpServlet.log(String, Exception)
it
 apparentrly works but I cant' find the log file, neither in
TOMCAT_HOME/log
 NOR ANYWHERE ELSE..
 Where is it? or has the log method an empty implementation or what?
 Using tomcat 3.2 on winnt
 Thanks

 -
 dott. Luca Davanzo
 Insiel S.p.A. - Direzione Tecnica
 Via G. Pieri, 2 - 33100 Udine
 Italy
 tel. +39-0432-551971
 * e-mail: [EMAIL PROTECTED]
 -






Re: tomcat+apache

2001-05-30 Thread Egidijus Drobavicius

WRONG
If you include generated configuration in apache conf, starting apache
before tomcat means that you dont use or you use outdated config of tomcat.
Therefore you always have to start tomcat first and apache second.
Regards,
Egidijus

- Original Message -
From: David DELGRANCHE [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, May 30, 2001 11:37 AM
Subject: RE: tomcat+apache


 You just have to start apache before starting Tomcat!

 David.

 -Message d'origine-
 De: unplug [SMTP:[EMAIL PROTECTED]]
 Date: mercredi 30 mai 2001 10:35
 A: tomcat-user
 Objet: tomcat+apache

 Hi all,

   Just install tomcat3.2.2 and mod_jk.so.  However, when I restart
 tomcat and then apache, I found the following message in mod_jk.log

 [jk_uri_worker_map.c (335)]: jk_uri_worker_map_t::uri_worker_map_close,
 NULL parameter
 [jk_uri_worker_map.c (185)]: In
 jk_uri_worker_map_t::uri_worker_map_free, NULL parameters

   What do they mean??  How do I configure to remove the message??

 Rgds,
 unplug






Re: java.lang.OutOfMemoryError

2001-05-25 Thread Egidijus Drobavicius

This is javaVM heap problem. You should increase heapsize. (e.g.
JAVACMD=java -mx200M)
Regards,
Egidijus
- Original Message -
From: Srinadh Karumuri [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, May 25, 2001 2:35 PM
Subject: RE: java.lang.OutOfMemoryError


 If you are wondering where that magic number came from. Try 'java' at the
 command line.
 Then try 'java -X' for the help on non-standard options. You will probably
 find another flag or two useful.

 Sri

 At 02:22 PM 05/25/2001 +0200, you wrote:
 i think your problems can be solved be setting a higher maximum heap
size.
 for example start tomcat by using java -Xmx256 ... to set heap size to
256
 mb.
 
 michael
 
 -Original Message-
 From: Shailesh R Sah [mailto:[EMAIL PROTECTED]]
 Sent: Friday, May 25, 2001 1:01 PM
 To: [EMAIL PROTECTED]
 Subject: java.lang.OutOfMemoryError
 
 
 hi,
 i am giving details as follows of my site and problem
 
 Server configuration :
 
 HardWare:
 Pentium 800 MHz.
 512 MB RAM
 18 GB Hard Disk
 Global line server.
 
 
 Software Loaded:
 Red Had linux 6.2
 Jdk1.2.2 for linux
 Jakarta-tomcat-3.2.1
 
 A Seperate Server is there for Oracle.
 
 Total No. of JSPs on the server:
 500Jsps
 
 Services Running:
 Apache, jakarta-tomcat
 
 Swap space:
 2GB
 
 From the Last 2-3 weeks
 1) The Tomcat is getting  killed automatically. This is happening more
 frequently sometimes 4
 
 times a day .The tomcat has to be started manually. The tomcat server is
 showing an error of out
 
 of memory(java.lang.OutOfMemoryError).Reports are attached in this
 document.
 
 
 2) The top service is not running. .
 
 3)Swap memory is 2GB
 
 
 What might be the possible possible reason???
 Is it that the tomcat cannot handle 500-600 Jsps??
 
 Kindly help out as the website is business critical.
 (See below for error details)
 
 As the problem is occuring daily.I am drawing a lot of flak at office as
 being a staunch
 
 supporter of open source and collabarative s/w movement i went for
 linux/tomcat combination.
 And now my decision is being questioned.Can u tell me of any source on
the
 basis of which i can
 
 present the case of linux/tomcat combination or sites using lots of
 jsps(500-600)
 
 
 
 
 I am giving below the error coming in the tomcat console.
 
 java.lang.OutOfMemoryError:
 at java.io.InputStreamReader.init(InputStreamReader.java:86)
 at java.io.InputStreamReader.init(InputStreamReader.java:55)
 at java.io.FileReader.init(FileReader.java:35)
 at
 _0002findex_0002ejspindex_jsp_3._jspService(_0002findex_0002ejspindex
 _jsp_3.java:634)
 at
 org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:126)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
 at
 org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspSer
 vlet.java:174)
 at
 org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:2
 61)
 at
 org.apache.jasper.runtime.JspServlet.service(JspServlet.java:369)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
 at
 org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.ja
 va:503)
 at
 org.apache.tomcat.core.ContextManager.service(ContextManager.java:559
 )
 at
 org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processCon
 nection(Ajp12ConnectionHandler.java:156)
 at
 org.apache.tomcat.service.TcpWorkerThread.run(PoolTcpEndpoint.java:36
 6)
 at
 org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java
 :411)
 at java.lang.Thread.run(Thread.java:475)
 java.lang.OutOfMemoryError:
 at
org.apache.tomcat.util.MimeHeaders.init(MimeHeaders.java:133)
 at
org.apache.tomcat.util.MimeHeaders.init(MimeHeaders.java:141)
 at
 org.apache.tomcat.core.ResponseImpl.init(ResponseImpl.java:96)
 at
 org.apache.tomcat.service.http.HttpResponseAdapter.init(HttpRespons
 eAdapter.java:91)
 at
 org.apache.tomcat.service.connector.AJP12ResponseAdapter.init(Ajp12
 ConnectionHandler.java:433)
 
 
 Thankx
 shailesh
 
 
 
 Srinadh Karumuri
 Senior Programmer/Analyst
 Business Apps.
 BBN Technologies (Verizon)
 Ph:(617)873-2841






Re: ===Session Question===

2001-05-22 Thread Egidijus Drobavicius

Use singleton. The way you described in your previuos design is not
singleton, singleton means one instance per application, your way was just
static class.
The basic idea would be smth like this
public class MySingleton {
 private MySingleton() {}; // constructor MUST be private
 private myInstance MySingleton; // this is your object;
 public MySingleton getInstance(){
 if (mInstance==null) mInstance=new MySingleton();
return mInstance;
 }
}

From your code to get to this object you will use MySingleton
obj=MySingleton.getInstance();
Hope this will help

Regards,
Egidijus

- Original Message -
From: anil [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, May 23, 2001 4:51 AM
Subject: Re: ===Session Question===


 Hi Warren,

 Thanks for the magic to destroy the session object when the response is
 delivered to client. That's the idea. I have some attributes that I do not
want
 to go away as long as tomcat lives but need to have the freedom to change.
some
 to live only for the request.
 Like say that I have a object graph like salesman list that does not
change very
 often. I want to keep them as context attribute. But on the
 customerDetailDisplay I want to keep the customer for the one single
request
 only where I got request for the CustomerDetail information.
 With Jserv, I used to keep them in a singleton (so called application
objects)
 .  Now with Tomcat 3.2.1 + Jboss 2.1, the salesman list might change once
in
 awhile (so that does not qualify as static type object), but it will stay
the
 same for long period of time.
 for recap:
 1. object graph that might change once in awhile, but will used by
different
 servlets
 (hope to keep them as context session object) - how???
 getContext.setAttribute(me,myGlobalObject);???

 2. object graph that should  live only for the request. OK:
 request.setAttribute(oh!my,myRequestObjet);
 next line always will be:

getServletConfig().getServletContext().getRequestDispatcher(page).forward();

 idea is to have the request hit the servlet Controller first and then go
to the
 view.

 How do you guys handle situation like this in tomcat??

 thanks

 anil


 Warren Crossing wrote:

  hi anil,
 
  i hope i've got your intention, you want to pass an object graph from
  servlet1 to servlet2.  tomcat provides session management through
  request.getSession().setAttribute() these objects are accessible for the
  duration of the session.  If you only want the object graph to live for
the
  lifespan of a single request then use request.setAttribute() and it will
  automatically destroy() when the response is returned to the
  tomcat-request-interceptor-responder-web-server-thingy ( i think that's
its'
  technical name ) ;
 
  warren.
 






Re: Session vs Beans

2001-05-21 Thread Egidijus Drobavicius

I think bean is much more clear approach. As i understood you have 2 ways --
store items directly to hashtable or store javabean and all you items into
this bean.
If you choose the first way the hashtable of the session would contain
pretty much of your crap and in case you want to dump all of it you will run
into problems which of these items are necessary for you and which were
placed by some other bean/jsp or so on.
If you use your own bean with a scope set to session (actually this would
place your bean to the _same_ hashtable of session object), you will have
all your form based valued concentrated in one single bean and that data
will be encapsulated.
When looking at performance and memory consumtion issues, the difference
will me so miserable that even computer would not be able to distinct :)
Regards,
Egidijus

- Original Message -
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, May 21, 2001 3:17 PM
Subject: Session vs Beans


 Last week I proposed this question to the discission group:

 I am currently writing a pretty complex data entry HTML page for an
 application.  The HTML has 7 different frames where data is input, one
 represents the master table and the others detail tables.  I am trying to
 come up with a way to keep all of the data entered into each frame for
 updating the database (I want to update all the records in one
 transaction).  There some obvious ways of doing this as with invisible
 fields on the master frame, and URL rewriting (cookies are out in this
 case) but I have also been looking into using the Session object.  I know
 the object is used for shopping carts on commercial web sites but would it
 be a good to use it to keep all the input values for various input forms?
 There will be from 40 - 50 items of data stored in the session object and
a
 user will only be able to have one form at a time?

 The unamious (and very helpful)  response was yes use a session object.

 Now however, I have learned to use Java Beans in JSP and was wondering, is
 it better to use a session object or a Java Bean with the scope set to
 session to store these values?

 Thanks for you help

 Jeff Sulman






Re: Apache 1.3.19/Tomcat 4.0B5 conf

2001-05-18 Thread Egidijus Drobavicius



Hey, why do all your messages require chinese 
simplified char set? Can you disable this?

  - Original Message - 
  From: 
  egcs12md 
  
  To: [EMAIL PROTECTED] 
  Sent: Friday, May 18, 2001 3:34 AM
  Subject: Apache 1.3.19/Tomcat 4.0B5 
  conf
  
  Has someone successfully use Apache 1.3.19 
  with Tomcat 4.0b5 in WinNT/Win2K,and how can I use Tomcat-Apache Engine in 
  %APACHE_HOME%\htdocs and all it's subdirectories 
?


POST File: weird situation

2001-05-15 Thread Egidijus Drobavicius

Hello,

I've ran into strange a bit situation:
i have to do file upload. I did this and there is no question about that.
The question is:
i want first verify all the data and then ask the user to confirm it. So i
get all inputs and do my check, then i'd like to generate a page that has
only 2 buttons submit and cancel, and on submit upload the data. Here the
problem comes. Is it possible to do that? I mean is there any way of doing
such a form? There is no attribute hidden for input type file. Is there any
way at least to set the value for this field?
I've tried using value=myfilename, but this does not work.

The problem can be solved by parsing all the data in the POST data request.
But this stream contains useful data and  I can not later retrieve it. E.g
stream has some_my_value one_more_value file_itself value
value_again another_file
I am not sure if the request can be served without knowledge about fields
value and value_again. However, to get these values i must skip maybe
useful information. I can not use temporary files for storing it.

Huh, if someone got what I am talking about, could you please share your
possible ideas with me.

Thanks,
Egidijus




Re: Posting multipart/form-data

2001-05-11 Thread Egidijus Drobavicius

Yes, I've dealt with similar problem. First, you have to use POST method to
upload files;
Second, you have to implement your doPost method to handle that kind of
request. All parameters, files etc are provided via input stream. If you
dont read single byte from that stream, you get this 404 error.
And most annoying thing is that Tomcat has a bug in ServletInputStream and
readLine does not actually read from the stream and says that there are no
bytes available.
What i did -- i did my own readLine method and read byte by byte from the
stream.
Steps that you have to do reading request:
1. retrieve boundary string
  String contentType = req.getContentType();
  int ind = contentType.indexOf(boundary=);
2. parse the input stream
You have to play with that a bit, see what the stream looks like.
When sending a response, set content type to text/html

use HttpServletRequest.getContentLength() to see the length of the content
and avoid upload of extremely large files.

Egidijus

- Original Message -
From: Brandon Cruz [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, May 11, 2001 12:25 AM
Subject: Posting multipart/form-data


 When I try to specify enctype=multipart/form-data, the page just goes
 blank and IE says that it can't find server.  Anyone know why this might
 happen?

 Brandon






Re: Apache with Tomcat configuration

2001-05-11 Thread Egidijus Drobavicius

Apache and tomcat talks on port 8007 using  Ajp12 protocol.
See if after tomvat startup if there is line like
Ajp12ConnectionHandler on 8007
Then try to telnet to this port (telnet yourhost 8007)
In tomcat console you shoud see exception
Maybe you set wrong communication either on apache side or on tomcat.
Ajp must use same port on both sides.

Egidijus

- Original Message -
From: Rao, Viswanatha [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, May 10, 2001 11:19 PM
Subject: Apache with Tomcat configuration


 When I configure Apache with Tomcat and invoke example Servlet, Apache
does
 not communicate the request to Tomcat.
 However Tomcat on port 8080 brings the servlet.

 If I change the Apache port from default 80 to any other port, then Apache
 and Tomcat talk to each other and servlet can be invoked through Apache.

 Can anyone help me?

 Regards
 Vishwa






Does tomcat undestant static classes?

2001-05-10 Thread Egidijus Drobavicius



I use one class as a collection of data items, such 
as
public static final String 
tmpDir="/u/somedir"
When I use this under W2000, it works. 
Under UNIX (SCO 506) i get

java.lang.IllegalStateException: Can't happen - 
classname is null, who added this ?	at 
org.apache.tomcat.core.ServletWrapper.loadServlet(ServletWrapper.java, Compiled 
Code)	at org.apache.tomcat.core.ServletWrapper.init(ServletWrapper.java, 
Compiled Code)	at org.apache.tomcat.core.Handler.service(Handler.java, 
Compiled Code)	at 
org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java, Compiled 
Code)	at 
org.apache.tomcat.core.ContextManager.handleStatus(ContextManager.java, Compiled 
Code)	at 
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java, 
Compiled Code)	at 
org.apache.tomcat.core.ContextManager.service(ContextManager.java, Compiled 
Code)	at 
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java, 
Compiled Code)	at 
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java, Compiled 
Code)	at 
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java, Compiled 
Code)	at java.lang.Thread.run(Thread.java, Compiled Code)

Could anyone explain what is this?

Thanks a lot

Egidijus DrobaviciusAB Vilniaus Bankashttp://www.vb.lttel. + 370 2 
682706


Re: jsp and servlet

2001-05-10 Thread Egidijus Drobavicius

According to JSP specification, objects with a scope application are stored
to context object's hashtable which is supposed to be one for the
application.
This means that if you store object once (jsp:useBean id=myBean
class=myclass scope=application/) each time later it will not be
created and useBean will return the same object.
From the servlet for retrieval i use context (i have HTTPServlet, and do
this.getServletContext().getAttribute(myBean))


- Original Message -
From: Andrea Mari [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, May 10, 2001 4:56 PM
Subject: jsp and servlet


 Hi,

 in a jsp page I have an object with scope application. Can I use this
object
 from a servlet?

 Thanks
 Andrea






SCO Unix: Apache and Tomcat do not cooperate

2001-05-08 Thread Egidijus Drobavicius



Hello,
I've moved from win2000 to SCO Unix and 
faced problems:
1. I was getting 403 Forbiden error. After 
I've changed all tomcat files to nouser:nogroup, this seems to be 
fixed
2. I've included tomcat-apache.conf to my 
httpd.conf, and if I access http://myhost/examples/ i see those pages; If 
I access servlets, they come occasionaly (meaning that I have to press few times 
refresh to get them working)
If I am to view *jsp examples, i get blank 
pages and error in console saying 

2001-05-08 11:41:24 - Ctx( /examples 
): IOException in: R( /examples +/jsp/num/numguess.jsp + null) Connection 
reset by peer

This happens both on IE and Nescape and as i said 
before, i see only blank screen.
jasper.log says

01-05-08 11:41:13 - 
 ServletPath: /jsp/num/numguess.jsp2001-05-08 
11:41:13 -  PathInfo: 
null2001-05-08 11:41:13 -  
RealPath: 
/var/opt/K/SCO/Unix/5.0.6Ga/usr/local/jakarta-tomcat-3.2.1/webapps/examples/jsp/num/numguess.jsp2001-05-08 
11:41:13 -  RequestURI: 
/examples/jsp/num/numguess.jsp2001-05-08 11:41:13 - 
 QueryString: null2001-05-08 11:41:13 - 
 Request Params: 2001-05-08 11:41:13 - Classpath according to 
the Servlet Engine is: 
/var/opt/K/SCO/Unix/5.0.6Ga/usr/local/jakarta-tomcat-3.2.1/webapps/examples/WEB-INF/classes

I use JServ module that came along with apache for 
tomcat-apache communication.

Egidijus DrobaviciusAB Vilniaus Bankashttp://www.vb.lttel. + 370 2 
682706