JSPs forcing session ID to be created?
Environment: Tomcat 5.5.17 using http connector, Servlet API 2.4. Hi All, I'm not sure where to go from here, so I'm going to assume it's a Catalina issue and go from there. I was working on a front controller that wouldn't instantiate a session unless absolutely necessary - (for scalability reasons) -- To my dismay, I was seeing a session created anyway. After some debugging, I came across the source of my problem: The following JSP will generate a session token: %@ taglib uri=http://java.sun.com/jsp/jstl/core; prefix=c % html head titleExample/title /head body h1Sample Form/h1 /body /html Here's the relevant stack trace. RequestFacade.getSession(boolean) line: 822 ApplicationHttpRequest(HttpServletRequestWrapper).getSession(boolean) line: 215 ApplicationHttpRequest.getSession(boolean) line: 544 ApplicationHttpRequest.getSession() line: 493 PageContextImpl._initialize(Servlet, ServletRequest, ServletResponse, String, boolean, int, boolean) line: 148 PageContextImpl.initialize(Servlet, ServletRequest, ServletResponse, String, boolean, int, boolean) line: 123 JspFactoryImpl.internalGetPageContext(Servlet, ServletRequest, ServletResponse, String, boolean, int, boolean) line: 104 JspFactoryImpl.getPageContext(Servlet, ServletRequest, ServletResponse, String, boolean, int, boolean) line: 61 Example.jsp line: not available Example_jsp(HttpJspBase).service(HttpServletRequest, HttpServletResponse) line: 97 Example_jsp(HttpServlet).service(ServletRequest, ServletResponse) line: 802 JspServletWrapper.service(HttpServletRequest, HttpServletResponse, boolean) line: 332 In this case, the boolean value for creating the session is true. I got some raw source code (older tomcat) and the _jspService looked like this: _jspxFactory = JspFactory.getDefaultFactory(); response.setContentType(text/html); pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true); _jspx_page_context = pageContext; application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); Is this really by design? Bug? Obviously, I'd rather not have a new session created until I need it. Is this situation submittable as a bug or am I misusing the library? Thanks in advance! -Mike - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: JSPs forcing session ID to be created?
Michael Rimov wrote: I was working on a front controller that wouldn't instantiate a session unless absolutely necessary - (for scalability reasons) -- To my dismay, I was seeing a session created anyway. After some debugging, I came across the source of my problem: The following JSP will generate a session token: %@ taglib uri=http://java.sun.com/jsp/jstl/core; prefix=c % html [...] Is this really by design? Bug? Obviously, I'd rather not have a new session created until I need it. Is this situation submittable as a bug or am I misusing the library? Try adding something like %@ page session=false % to your JSP. Regards mks - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: JSPs forcing session ID to be created?
Try adding something like %@ page session=false % to your JSP. Ugh, yup! That did it -- Been programming Servlets/JSP since about '98 and never knew that. :) Thank you very much! -Mike - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: JSPs forcing session ID to be created?
In your jsp %@ page session=false Is this what you're looking for?? Martin -- This email message and any files transmitted with it contain confidential information intended only for the person(s) to whom this email message is addressed. If you have received this email message in error, please notify the sender immediately by telephone or email and destroy the original message without making a copy. Thank you. - Original Message - From: Pid [EMAIL PROTECTED] To: Tomcat Users List users@tomcat.apache.org Sent: Sunday, June 25, 2006 8:40 AM Subject: Re: JSPs forcing session ID to be created? I think Tomcat creates a session, unless you tell it otherwise. http://wiki.jboss.org/wiki/Wiki.jsp?page=DisableSessionPersistence I repeat the popular refrain Google is your friend. Michael Rimov wrote: Environment: Tomcat 5.5.17 using http connector, Servlet API 2.4. Hi All, I'm not sure where to go from here, so I'm going to assume it's a Catalina issue and go from there. I was working on a front controller that wouldn't instantiate a session unless absolutely necessary - (for scalability reasons) -- To my dismay, I was seeing a session created anyway. After some debugging, I came across the source of my problem: The following JSP will generate a session token: %@ taglib uri=http://java.sun.com/jsp/jstl/core; prefix=c % html head titleExample/title /head body h1Sample Form/h1 /body /html Here's the relevant stack trace. RequestFacade.getSession(boolean) line: 822 ApplicationHttpRequest(HttpServletRequestWrapper).getSession(boolean) line: 215 ApplicationHttpRequest.getSession(boolean) line: 544 ApplicationHttpRequest.getSession() line: 493 PageContextImpl._initialize(Servlet, ServletRequest, ServletResponse, String, boolean, int, boolean) line: 148 PageContextImpl.initialize(Servlet, ServletRequest, ServletResponse, String, boolean, int, boolean) line: 123 JspFactoryImpl.internalGetPageContext(Servlet, ServletRequest, ServletResponse, String, boolean, int, boolean) line: 104 JspFactoryImpl.getPageContext(Servlet, ServletRequest, ServletResponse, String, boolean, int, boolean) line: 61 Example.jsp line: not available Example_jsp(HttpJspBase).service(HttpServletRequest, HttpServletResponse) line: 97 Example_jsp(HttpServlet).service(ServletRequest, ServletResponse) line: 802 JspServletWrapper.service(HttpServletRequest, HttpServletResponse, boolean) line: 332 In this case, the boolean value for creating the session is true. I got some raw source code (older tomcat) and the _jspService looked like this: _jspxFactory = JspFactory.getDefaultFactory(); response.setContentType(text/html); pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true); _jspx_page_context = pageContext; application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); Is this really by design? Bug? Obviously, I'd rather not have a new session created until I need it. Is this situation submittable as a bug or am I misusing the library? Thanks in advance! -Mike - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: log4j warning: Please initialize the log4j system properly
Can anyone point me to a direction? I have no clue what is wrong, and all the posts I have found all suggest to place the log4j.properties in the common/classes dir. I have done this and it is not working. It seems log4j is working, but the log4j config isn't working properly for some reason. I think this line is causing some problems for you: log4j.logger.org.apache.catalina=DEBUG, R Don't see why actually... [CATALINA_HOME]/common/classes/log4j.properties: log4j.rootLogger=ERROR, R log4j.appender.R=org.apache.log4j.RollingFileAppender log4j.appender.R.File=C:\Program Files\Apache Software Foundation\Tomcat 5.5\logs\tomcat.log log4j.appender.R.MaxFileSize=10MB log4j.appender.R.MaxBackupIndex=10 log4j.appender.R.layout=org.apache.log4j.PatternLayout log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n log4j.logger.org.apache.catalina=DEBUG, R Maybe you should try putting the appender stuff at the bottom, and the loggger things on top. Also, you don't need to repeat the R. I would try this config once: log4j.rootLogger=ERROR, R log4j.logger.org.apache.catalina=DEBUG log4j.appender.R=org.apache.log4j.RollingFileAppender log4j.appender.R.File=C:\Program Files\Apache Software Foundation\Tomcat 5.5\logs\tomcat.log log4j.appender.R.MaxFileSize=10MB log4j.appender.R.MaxBackupIndex=10 log4j.appender.R.layout=org.apache.log4j.PatternLayout log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n --Velpi - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
in tomca 5 .0.* my security constraint is not working why
hi even i put jsp page in protected folder i am able to access them directly in tomcat 5.0. i am able to access these resticted pages directly http://localhost:8080/protected/*.jsp what i have to do to restrict this this is my web.xml page ?xml version=1.0 encoding=UTF-8? web-app version=2.4 xmlns=http://java.sun.com/xml/ns/j2ee; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd; display-nameChartCreatorWebApp/display-name security-constraint web-resources-collection web-resources-nameprotected/web-resources-name url-pattern/protected/*.jsp/url-pattern /web-resources-collection /security-constraint welcome-file-list welcome-filefirst.jsp/welcome-file /welcome-file-list resource-ref descriptionOracle Datasource example/description res-ref-namejdbc/myoracle/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref /web-app do tell to put folder in web-inf folder -- View this message in context: http://www.nabble.com/in-tomca-5-.0.*-my-security-constraint-is-not-working-why-t1844865.html#a5035656 Sent from the Tomcat - User forum at Nabble.com. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Tomcat multiple init(), no init param
Tomcat 5.5.16 seems to call a servlet's init() method several times, and the specific init parameter is missing in all but the first. I have a simple server.xml that includes: Host name=www.example.com appBase=/var/web/apps unpackWARs=false autoDeploy=false xmlValidation=false xmlNamespaceAware=false Aliasexample.com/Alias Context path= docBase=www.example.com.war Parameter name=dataDirectory value=/var/web/data/www.example.com// /Context /Host In www.example.com.war I have a web.xml file that includes two instances of MyServlet, with servlet names of myServlet1 and myServlet2, mapped to /* and /example/*, respectively. Tomcat does the following, which I find odd: 1. myServlet1.init() is called. The init parameter dataDirectory is correctly set to /var/web/data/www.example.com/. 2. catalina.out indicates Jun 25, 2006 2:07:26 PM org.apache.catalina.startup.HostConfig deployWAR. 3. myServlet.init is called(). The init parameter dataDirectory returns null. 4. myServlet2.init is called(). The init parameter dataDirectory returns null. (Then steps 3 and 4 are repeated, presumably because steps 2 and 3 throw NullPointerExceptions, which results from the missing init parameter.) This confuses me: * Why is myServlet1.init() called twice? * Why isn't myServlet2.init() called before the second call to myServlet1.init()? * Why is the init parameter dataDirectory only available in the first call to myServlet1.init()? Thanks for any insight, Garret - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Tomcat multiple init(), no init param
Everyone, I found the answer to my second question, Why isn't myServlet2.init() called before the second call to myServlet1.init()? It turns out it was being called, but my debug trace statements had been redirected because my init() method had successfully redirected debug output. So the sequence now looks like this: 1. myServlet1.init() is called. The init parameter dataDirectory is correctly set to /var/web/data/www.example.com/, and debug output is successfully redirected. 2. myServlet2.init() is called. The init parameter dataDirectory is correctly set to /var/web/data/www.example.com/, and debug output is still successfully redirected. 3. catalina.out indicates Jun 25, 2006 4:23:40 PM org.apache.catalina.startup.HostConfig deployWAR followed by INFO: Deploying web application archive www.example.com.war 4. myServlet1.init() is called. The init parameter dataDirectory returns null, the static variable is no longer set, and output is no longer redirected. 5. myServlet2.init() is called. The init parameter dataDirectory returns null, the static variable is no longer set, and output is no longer redirected.. Note that in step 1 I set a static variable in my servlet that is verified in step 2. But by step 4 the static variable is gone! Note that if I change unpackWARs=true, these errors still occur, even if I restart Tomcat after the WARs have been unpacked! (The only difference is that, in step 4, I have access to the real path of the WEB-INF directory.) It's as if two instances of Tomcat are being run in two separate JVMS: one using the server.xml configuration, and another attempting to deploy the .war files using some default configuration. The first set of initialized servlets continue to run and accept connections. What's wrong here? Thanks in advance, Garret Garret Wilson wrote: Tomcat 5.5.16 seems to call a servlet's init() method several times, and the specific init parameter is missing in all but the first. I have a simple server.xml that includes: Host name=www.example.com appBase=/var/web/apps unpackWARs=false autoDeploy=false xmlValidation=false xmlNamespaceAware=false Aliasexample.com/Alias Context path= docBase=www.example.com.war Parameter name=dataDirectory value=/var/web/data/www.example.com// /Context /Host In www.example.com.war I have a web.xml file that includes two instances of MyServlet, with servlet names of myServlet1 and myServlet2, mapped to /* and /example/*, respectively. Tomcat does the following, which I find odd: 1. myServlet1.init() is called. The init parameter dataDirectory is correctly set to /var/web/data/www.example.com/. 2. catalina.out indicates Jun 25, 2006 2:07:26 PM org.apache.catalina.startup.HostConfig deployWAR. 3. myServlet.init is called(). The init parameter dataDirectory returns null. 4. myServlet2.init is called(). The init parameter dataDirectory returns null. (Then steps 3 and 4 are repeated, presumably because steps 2 and 3 throw NullPointerExceptions, which results from the missing init parameter.) This confuses me: * Why is myServlet1.init() called twice? * Why isn't myServlet2.init() called before the second call to myServlet1.init()? * Why is the init parameter dataDirectory only available in the first call to myServlet1.init()? Thanks for any insight, Garret - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Tomcat multiple init(), no init param
Garret Wilson wrote: It's as if two instances of Tomcat are being run in two separate JVMS: one using the server.xml configuration, and another attempting to deploy the .war files using some default configuration. The first set of initialized servlets continue to run and accept connections. What's wrong here? I've found the problem. If you remember, my server.xml had this: Host name=www.example.com appBase=/var/web/apps unpackWARs=false autoDeploy=false xmlValidation=false xmlNamespaceAware=false Aliasexample.com/Alias Context path= docBase=www.example.com.war Parameter name=dataDirectory value=/var/web/data/www.example.com// /Context /Host Tomcat would deploy my .war file as specified, using the given init parameter. But then, because my .war file was in the appBase directory (here /var/web/apps), Tomcat would going through and deploying the .war file a second time even though autoDeploy was set to false. One way to fix this it to change the appBase so that my .war file wasn't in the application base directory: Host name=www.example.com appBase=/var/web unpackWARs=false autoDeploy=false xmlValidation=false xmlNamespaceAware=false Aliasexample.com/Alias Context path= docBase=apps/www.example.com.war Parameter name=dataDirectory value=/var/web/data/www.example.com// /Context /Host But the easier way is to add deployOnStartup=false to the host configuration, like this: Host name=www.example.com appBase=/var/web/apps unpackWARs=false autoDeploy=false deployOnStartup=false xmlValidation=false xmlNamespaceAware=false Aliasexample.com/Alias Context path= docBase=www.example.com.war Parameter name=dataDirectory value=/var/web/data/www.example.com// /Context /Host Sure enough, there is a small note on this at http://tomcat.apache.org/tomcat-5.5-doc/config/host.html#Automatic%20Application%20Deployment : When using automatic deployment, the docBase defined by an XML Context file should be outside of the appBase directory. If this is not the case difficulties may be experienced deploying the web application or the application may be deployed twice. Well, that's why I turned off autoDeploy---but it seems I need to turn off deployOnStartup as well. Garret Thanks in advance, Garret Garret Wilson wrote: Tomcat 5.5.16 seems to call a servlet's init() method several times, and the specific init parameter is missing in all but the first. I have a simple server.xml that includes: Host name=www.example.com appBase=/var/web/apps unpackWARs=false autoDeploy=false xmlValidation=false xmlNamespaceAware=false Aliasexample.com/Alias Context path= docBase=www.example.com.war Parameter name=dataDirectory value=/var/web/data/www.example.com// /Context /Host In www.example.com.war I have a web.xml file that includes two instances of MyServlet, with servlet names of myServlet1 and myServlet2, mapped to /* and /example/*, respectively. Tomcat does the following, which I find odd: 1. myServlet1.init() is called. The init parameter dataDirectory is correctly set to /var/web/data/www.example.com/. 2. catalina.out indicates Jun 25, 2006 2:07:26 PM org.apache.catalina.startup.HostConfig deployWAR. 3. myServlet.init is called(). The init parameter dataDirectory returns null. 4. myServlet2.init is called(). The init parameter dataDirectory returns null. (Then steps 3 and 4 are repeated, presumably because steps 2 and 3 throw NullPointerExceptions, which results from the missing init parameter.) This confuses me: * Why is myServlet1.init() called twice? * Why isn't myServlet2.init() called before the second call to myServlet1.init()? * Why is the init parameter dataDirectory only available in the first call to myServlet1.init()? Thanks for any insight, Garret - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: query
Oracle also installs its own jdk and may have changed the environment settings have you checked the java version at command prompt. Notmally Oracle jdk is 1.3 and installed inside Oracle home dir. Also you may want to try running tomcat from command prompt, it may show some errors. -Sameer veena v [EMAIL PROTECTED] wrote: There is no error message. Tomcat does start and automatically shuts down. On 6/22/06, Sameer Acharya wrote: What are the error messages you are seeing during tomcat startup ? Or try giving the log. -Sameer veena v wrote: I have windows xp installed on my system. I installed tomcat 4.1 and it was working properly. But after installing oracle 9i tomcat is not working though i have installed tomcat and oracle on different port. Please do help me. - Do you Yahoo!? Next-gen email? Have it all with the all-new Yahoo! Mail Beta. - Sneak preview the all-new Yahoo.com. It's not radically different. Just radically better.
Using Datasource for cloudscape
Hi there, can anybody help me on this. Hi Dilan have you any more clue on this. Problem: I am using Tomcat 5.5.17 and tried running a sample datasource application having a jsp page (see contents below) using the Cloudscape database. I have added the driver jar into CATALINA_HOME/common/lib directory. When I run the jsp I get following exception WARNING: Unexpected exception resolving reference java.lang.NoSuchMethodException: com.ibm.db2j.jdbc.DB2jDataSource.setScope(boolean) at java.lang.Class.getMethod(Class.java:1581) at com.ibm.db2j.jdbc.DB2jAbstractDataSource.getObjectInstance(Unknown Source) Contents of file CATALINA_HOME/webapps/myApp/dbdemo.jsp %@ page import=javax.sql.* % %@ page import=java.sql.* % %@ page import=javax.naming.* % % Connection con = null; Statement stmt = null; try { Context initContext = new InitialContext(); Context envContext = (Context)initContext.lookup(java:comp/env); DataSource ds = (DataSource)envContext.lookup(jdbc/MyDB); System.out.println(Got DataSource\n); con = ds.getConnection(); System.out.println(Got Connection\n); } catch(java.lang.Exception e) { e.printStackTrace(); System.err.print(e.getClass().getName()); System.err.println(e.getMessage()); } try { stmt = con.createStatement(); ResultSet rs = stmt.executeQuery(SELECT * FROM employee); System.out.println(Table assignment after insertion:); % Your table contains the following entries:BR table trBthemp_id/ththemp_name/ththemp_dept/th/B/tr % while (rs.next()) { String emp_id = rs.getString(emp_id); String emp_name = rs.getString(emp_name); String emp_dept = rs.getString(emp_dept); % tr td%=emp_id%/tdtd%=emp_name%/tdtd%=emp_dept%/td /tr /table % } rs.close(); stmt.close(); con.close(); } catch(java.lang.Exception e) { e.printStackTrace(); }% Contents of file CATALINA_HOME/conf/server.xml ?xml version=1.0 encoding=UTF-8? Server Listener className=org.apache.catalina.core.AprLifecycleListener/ Listener className=org.apache.catalina.mbeans.GlobalResourcesLifecycleListener/ Listener className=org.apache.catalina.storeconfig.StoreConfigLifecycleListener / Listener className=org.apache.catalina.mbeans.ServerLifecycleListener/ GlobalNamingResources Environment name=simpleValue type=java.lang.Integer value=30/ Resource auth=Container description=User database that can be updated and saved name=UserDatabase type=org.apache.catalina.UserDatabase pathname=conf/tomcat-users.xml factory=org.apache.catalina.users.MemoryUserDatabaseFactory/ Resource name=jdbc/MyDB type=javax.sql.DataSource password=password driverClassName=com.ibm.db2j.jdbc.DB2jDriver maxIdle=2 maxWait=5000 username=user url=jdbc:db2j:E:/apache-tomcat-5.5.17/webapps/datasourcedemo/SampleDB maxActive=4/ /GlobalNamingResources Service name=Catalina Connector port=8080 redirectPort=8443 minSpareThreads=25 connectionTimeout=2 maxSpareThreads=75 maxThreads=150 /Connector Connector port=8009 redirectPort=8443 protocol=AJP/1.3 /Connector Engine defaultHost=localhost name=Catalina Realm className=org.apache.catalina.realm.UserDatabaseRealm/ Host appBase=webapps name=localhost /Host /Engine /Service /Server Contents of file CATALINA_HOME/webapps/myApp/WEB-INF/web.xml ?xml version=1.0 encoding=UTF-8? web-app id=WebApp_ID version=2.4 xmlns=http://java.sun.com/xml/ns/j2ee; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd; display-name datasourcedemo/display-name welcome-file-list welcome-fileindex.html/welcome-file welcome-fileindex.htm/welcome-file welcome-fileindex.jsp/welcome-file welcome-filedefault.html/welcome-file welcome-filedefault.htm/welcome-file welcome-filedefault.jsp/welcome-file /welcome-file-list resource-ref res-ref-namejdbc/MyDB/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref /web-app