ConnectException when using Tomcat 4.1
Hi,
I'm trying to run my web application with Tomcat 4.1 (until now I worked with Tomcat 3.2, and didn't have problems).
In my application I have an applet that reads from a file (the file is located on the web server.)
When I try to do it (using Url.openStream()) I get:
java.net.ConnectException: Connection refused.
I guess I have to configure some kind of permissions in the tomcat configuration files or something like that, but I didn't find anything.
(In my Java policy tool I made sure to give java.security.AllPermission, but I'm not sure that it's connected).
Can you please help me?...
Thanks,
Efrat
The code the I use is:
// With a URL now available, try to esatablish a read
// mechanism and read in the file as a series of String lines
try
InputStream is = sourceUrl.openStream();
InputStreamReader isr = new InputStreamReader (is);
BufferedReader d = new BufferedReader (isr);
return (readLines(d));
catch (java.io.FileNotFoundException iof)
Debug.err ("FileNotFoundException: " + iof);
JOptionPane.showMessageDialog(applet, "Problems with web server were discovered. Device image will not be shown.\nPlease check server and device status and correct, then try to login again.");
return null;
catch (IOException e)
Debug.err ("exception in fetchLines: " + e);
e.printStackTrace();
return null;
The exception that I get is:
exception in fetchLines: java.net.ConnectException: Connection refused: connect
java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
at java.net.Socket.connect(Socket.java:426)
at sun.net.NetworkClient.doConnect(NetworkClient.java:137)
at sun.plugin.net.protocol.http.HttpClient.doConnect(HttpClient.java:93)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:386)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:602)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:303)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:264)
at sun.plugin.net.protocol.http.HttpClient.<init>(HttpClient.java:39)
at sun.plugin.net.protocol.http.HttpClient.New(HttpClient.java:66)
at sun.plugin.net.protocol.http.HttpURLConnection.privBlock(HttpURLConnection.java:116)
at sun.plugin.net.protocol.http.HttpURLConnection$PrivilegedBlockAction.run(HttpURLConnection.java:460)
at java.security.AccessController.doPrivileged(Native Method)
at sun.plugin.net.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:167)
at sun.plugin.net.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:375)
at java.net.URL.openStream(URL.java:960)
at pic1.AtricaFetchConfig.fetchLines(AtricaFetchConfig.java:30)
at pic1.AtricaDeviceObj.buildConfig(AtricaDeviceObj.java:105)
at pic1.AtricaDeviceObj.buildDevice(AtricaDeviceObj.java:39)
at pic1.nicApplet.fetchDevice(nicApplet.java:110)
at pic1.nicApplet.init(nicApplet.java:49)
at sun.applet.AppletPanel.run(AppletPanel.java:347)
at java.lang.Thread.run(Thread.java:536)
I get the exception when doing: InputStream is = sourceUrl.openStream();
Thanks a lot,
Efrat
Similar Messages
-
Exception report when using tomcat 5 with JDBC
i followed this guide to setup the JDBC with my TOMCAT 5
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html#Database%20Connection%20Pool%20(DBCP)%20Configurations
but i seem to get this error
exception
javax.servlet.ServletException: Unable to get connection, DataSource invalid: "org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'"
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:846)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
org.apache.jsp.SID.test_jsp._jspService(test_jsp.java:81)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'"
org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.getConnection(QueryTagSupport.java:276)
org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.doStartTag(QueryTagSupport.java:159)
org.apache.jsp.SID.test_jsp._jspx_meth_sql_query_0(test_jsp.java:100)
org.apache.jsp.SID.test_jsp._jspService(test_jsp.java:58)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
i can compile *.java and run them when they need the jdbc drivers to interact with mysql 5 database.
This is my server.xml
<!-- Example Server Configuration File -->
<!-- Note that component elements are nested corresponding to their
parent-child relationships with each other -->
<!-- A "Server" is a singleton element that represents the entire JVM,
which may contain one or more "Service" instances. The Server
listens for a shutdown command on the indicated port.
Note: A "Server" is not itself a "Container", so you may not
define subcomponents such as "Valves" or "Loggers" at this level.
-->
<Server port="8005" shutdown="SHUTDOWN" debug="0">
<!-- Comment these entries out to disable JMX MBeans support -->
<!-- You may also configure custom components (e.g. Valves/Realms) by
including your own mbean-descriptor file(s), and setting the
"descriptors" attribute to point to a ';' seperated list of paths
(in the ClassLoader sense) of files to add to the default list.
e.g. descriptors="/com/myfirm/mypackage/mbean-descriptor.xml"
-->
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"
debug="0"/>
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"
debug="0"/>
<!-- Global JNDI resources -->
<GlobalNamingResources>
<!-- Test entry for demonstration purposes -->
<Environment name="simpleValue" type="java.lang.Integer" value="30"/>
<!-- Editable user database that can also be used by
UserDatabaseRealm to authenticate users -->
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved">
</Resource>
<ResourceParams name="UserDatabase">
<parameter>
<name>factory</name>
<value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
</parameter>
<parameter>
<name>pathname</name>
<value>conf/tomcat-users.xml</value>
</parameter>
</ResourceParams>
</GlobalNamingResources>
<!-- A "Service" is a collection of one or more "Connectors" that share
a single "Container" (and therefore the web applications visible
within that Container). Normally, that Container is an "Engine",
but this is not required.
Note: A "Service" is not itself a "Container", so you may not
define subcomponents such as "Valves" or "Loggers" at this level.
-->
<!-- Define the Tomcat Stand-Alone Service -->
<Service name="Catalina">
<!-- A "Connector" represents an endpoint by which requests are received
and responses are returned. Each Connector passes requests on to the
associated "Container" (normally an Engine) for processing.
By default, a non-SSL HTTP/1.1 Connector is established on port 8080.
You can also enable an SSL HTTP/1.1 Connector on port 8443 by
following the instructions below and uncommenting the second Connector
entry. SSL support requires the following steps (see the SSL Config
HOWTO in the Tomcat 5 documentation bundle for more detailed
instructions):
* If your JDK version 1.3 or prior, download and install JSSE 1.0.2 or
later, and put the JAR files into "$JAVA_HOME/jre/lib/ext".
* Execute:
%JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA (Windows)
$JAVA_HOME/bin/keytool -genkey -alias tomcat -keyalg RSA (Unix)
with a password value of "changeit" for both the certificate and
the keystore itself.
By default, DNS lookups are enabled when a web application calls
request.getRemoteHost(). This can have an adverse impact on
performance, so you can disable it by setting the
"enableLookups" attribute to "false". When DNS lookups are disabled,
request.getRemoteHost() will return the String version of the
IP address of the remote client.
-->
<!-- Define a non-SSL Coyote HTTP/1.1 Connector on port 8080 -->
<Connector port="8080"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
debug="0" connectionTimeout="20000"
disableUploadTimeout="true" />
<!-- Note : To disable connection timeouts, set connectionTimeout value
to 0 -->
<!-- Note : To use gzip compression you could set the following properties :
compression="on"
compressionMinSize="2048"
noCompressionUserAgents="gozilla, traviata"
compressableMimeType="text/html,text/xml"
-->
<!-- Define a SSL Coyote HTTP/1.1 Connector on port 8443 -->
<!--
<Connector port="8443"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" disableUploadTimeout="true"
acceptCount="100" debug="0" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" />
-->
<!-- Define a Coyote/JK2 AJP 1.3 Connector on port 8009 -->
<Connector port="8009"
enableLookups="false" redirectPort="8443" debug="0"
protocol="AJP/1.3" />
<!-- Define a Proxied HTTP/1.1 Connector on port 8082 -->
<!-- See proxy documentation for more information about using this. -->
<!--
<Connector port="8082"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false"
acceptCount="100" debug="0" connectionTimeout="20000"
proxyPort="80" disableUploadTimeout="true" />
-->
<!-- An Engine represents the entry point (within Catalina) that processes
every request. The Engine implementation for Tomcat stand alone
analyzes the HTTP headers included with the request, and passes them
on to the appropriate Host (virtual host). -->
<!-- You should set jvmRoute to support load-balancing via JK/JK2 ie :
<Engine name="Standalone" defaultHost="localhost" debug="0" jvmRoute="jvm1">
-->
<!-- Define the top level container in our container hierarchy -->
<Engine name="Catalina" defaultHost="localhost" debug="0">
<!-- The request dumper valve dumps useful debugging information about
the request headers and cookies that were received, and the response
headers and cookies that were sent, for all requests received by
this instance of Tomcat. If you care only about requests to a
particular virtual host, or a particular application, nest this
element inside the corresponding <Host> or <Context> entry instead.
For a similar mechanism that is portable to all Servlet 2.4
containers, check out the "RequestDumperFilter" Filter in the
example application (the source for this filter may be found in
"$CATALINA_HOME/webapps/examples/WEB-INF/classes/filters").
Request dumping is disabled by default. Uncomment the following
element to enable it. -->
<!--
<Valve className="org.apache.catalina.valves.RequestDumperValve"/>
-->
<!-- Global logger unless overridden at lower levels -->
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="catalina_log." suffix=".txt"
timestamp="true"/>
<!-- Because this Realm is here, an instance will be shared globally -->
<!-- This Realm uses the UserDatabase configured in the global JNDI
resources under the key "UserDatabase". Any edits
that are performed against this UserDatabase are immediately
available for use by the Realm. -->
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
debug="0" resourceName="UserDatabase"/>
<!-- Comment out the old realm but leave here for now in case we
need to go back quickly -->
<!--
<Realm className="org.apache.catalina.realm.MemoryRealm" />
-->
<!-- Replace the above Realm with one of the following to get a Realm
stored in a database and accessed via JDBC -->
<!--
<Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
driverName="org.gjt.mm.mysql.Driver"
connectionURL="jdbc:mysql://localhost/authority"
connectionName="test" connectionPassword="test"
userTable="users" userNameCol="user_name" userCredCol="user_pass"
userRoleTable="user_roles" roleNameCol="role_name" />
-->
<!--
<Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
driverName="oracle.jdbc.driver.OracleDriver"
connectionURL="jdbc:oracle:thin:@ntserver:1521:ORCL"
connectionName="scott" connectionPassword="tiger"
userTable="users" userNameCol="user_name" userCredCol="user_pass"
userRoleTable="user_roles" roleNameCol="role_name" />
-->
<!--
<Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
driverName="sun.jdbc.odbc.JdbcOdbcDriver"
connectionURL="jdbc:odbc:CATALINA"
userTable="users" userNameCol="user_name" userCredCol="user_pass"
userRoleTable="user_roles" roleNameCol="role_name" />
-->
<!-- Define the default virtual host
Note: XML Schema validation will not work with Xerces 2.2.
-->
<Host name="localhost" debug="0" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<!-- Defines a cluster for this node,
By defining this element, means that every manager will be changed.
So when running a cluster, only make sure that you have webapps in there
that need to be clustered and remove the other ones.
A cluster has the following parameters:
className = the fully qualified name of the cluster class
name = a descriptive name for your cluster, can be anything
debug = the debug level, higher means more output
mcastAddr = the multicast address, has to be the same for all the nodes
mcastPort = the multicast port, has to be the same for all the nodes
mcastBindAddr = bind the multicast socket to a specific address
mcastTTL = the multicast TTL if you want to limit your broadcast
mcastSoTimeout = the multicast readtimeout
mcastFrequency = the number of milliseconds in between sending a "I'm alive" heartbeat
mcastDropTime = the number a milliseconds before a node is considered "dead" if no heartbeat is received
tcpThreadCount = the number of threads to handle incoming replication requests, optimal would be the same amount of threads as nodes
tcpListenAddress = the listen address (bind address) for TCP cluster request on this host,
in case of multiple ethernet cards.
auto means that address becomes
InetAddress.getLocalHost().getHostAddress()
tcpListenPort = the tcp listen port
tcpSelectorTimeout = the timeout (ms) for the Selector.select() method in case the OS
has a wakup bug in java.nio. Set to 0 for no timeout
printToScreen = true means that managers will also print to std.out
expireSessionsOnShutdown = true means that
useDirtyFlag = true means that we only replicate a session after setAttribute,removeAttribute has been called.
false means to replicate the session after each request.
false means that replication would work for the following piece of code:
<%
HashMap map = (HashMap)session.getAttribute("map");
map.put("key","value");
%>
replicationMode = can be either 'pooled', 'synchronous' or 'asynchronous'.
* Pooled means that the replication happens using several sockets in a synchronous way. Ie, the data gets replicated, then the request return. This is the same as the 'synchronous' setting except it uses a pool of sockets, hence it is multithreaded. This is the fastest and safest configuration. To use this, also increase the nr of tcp threads that you have dealing with replication.
* Synchronous means that the thread that executes the request, is also the
thread the replicates the data to the other nodes, and will not return until all
nodes have received the information.
* Asynchronous means that there is a specific 'sender' thread for each cluster node,
so the request thread will queue the replication request into a "smart" queue,
and then return to the client.
The "smart" queue is a queue where when a session is added to the queue, and the same session
already exists in the queue from a previous request, that session will be replaced
in the queue instead of replicating two requests. This almost never happens, unless there is a
large network delay.
-->
<!--
When configuring for clustering, you also add in a valve to catch all the requests
coming in, at the end of the request, the session may or may not be replicated.
A session is replicated if and only if all the conditions are met:
1. useDirtyFlag is true or setAttribute or removeAttribute has been called AND
2. a session exists (has been created)
3. the request is not trapped by the "filter" attribute
The filter attribute is to filter out requests that could not modify the session,
hence we don't replicate the session after the end of this request.
The filter is negative, ie, anything you put in the filter, you mean to filter out,
ie, no replication will be done on requests that match one of the filters.
The filter attribute is delimited by ;, so you can't escape out ; even if you wanted to.
filter=".*\.gif;.*\.js;" means that we will not replicate the session after requests with the URI
ending with .gif and .js are intercepted.
The deployer element can be used to deploy apps cluster wide.
Currently the deployment only deploys/undeploys to working members in the cluster
so no WARs are copied upons startup of a broken node.
The deployer watches a directory (watchDir) for WAR files when watchEnabled="true"
When a new war file is added the war gets deployed to the local instance,
and then deployed to the other instances in the cluster.
When a war file is deleted from the watchDir the war is undeployed locally
and cluster wide
-->
<!--
<Cluster className="org.apache.catalina.cluster.tcp.SimpleTcpCluster"
managerClassName="org.apache.catalina.cluster.session.DeltaManager"
expireSessionsOnShutdown="false"
useDirtyFlag="true">
<Membership
className="org.apache.catalina.cluster.mcast.McastService"
mcastAddr="228.0.0.4"
mcastPort="45564"
mcastFrequency="500"
mcastDropTime="3000"/>
<Receiver
className="org.apache.catalina.cluster.tcp.ReplicationListener"
tcpListenAddress="auto"
tcpListenPort="4001"
tcpSelectorTimeout="100"
tcpThreadCount="6"/>
<Sender
className="org.apache.catalina.cluster.tcp.ReplicationTransmitter"
replicationMode="pooled"/>
<Valve className="org.apache.catalina.cluster.tcp.ReplicationValve"
filter=".*\.gif;.*\.js;.*\.jpg;.*\.htm;.*\.html;.*\.txt;"/>
<Deployer className="org.apache.catalina.cluster.deploy.FarmWarDeployer"
tempDir="/tmp/war-temp/"
deployDir="/tmp/war-deploy/"
watchDir="/tmp/war-listen/"
watchEnabled="false"/>
</Cluster>
-->
<!-- Normally, users must authenticate themselves to each web app
individually. Uncomment the following entry if you would like
a user to be authenticated the first time they encounter a
resource protected by a security constraint, and then have that
user identity maintained across all web applications contained
in this virtual host. -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn"
debug="0"/>
-->
<!-- Access log processes all requests for this virtual host. By
default, log files are created in the "logs" directory relative to
$CATALINA_HOME. If you wish, you can specify a different
directory with the "directory" attribute. Specify either a relative
(to $CATALINA_HOME) or absolute path to the desired directory.
-->
<!--
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs" prefix="localhost_access_log." suffix=".txt"
pattern="common" resolveHosts="false"/>
-->
<!-- Logger shared by all Contexts related to this virtual host. By
default (when using FileLogger), log files are created in the "logs"
directory relative to $CATALINA_HOME. If you wish, you can specify
a different directory with the "directory" attribute. Specify either a
relative (to $CATALINA_HOME) or absolute path to the desired
directory.-->
<Logger className="org.apache.catalina.logger.FileLogger"
directory="logs" prefix="localhost_log." suffix=".txt"
timestamp="true"/>
<Context path="/testdb" docBase="APACHE_DIR/htdocs/testdb"
debug="5" reloadable="true" crossContext="true">
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="localhost_DBTest_log." suffix=".txt"
timestamp="true"/>
<Resource name="jdbc/TestDB"
auth="Container"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/TestDB">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<!-- Maximum number of dB connections in pool. Make sure you
configure your mysqld max_connections large enough to handle
all of your db connections. Set to 0 for no limit.
-->
<parameter>
<name>maxActive</name>
<value>10</value>
</parameter>
<!-- Maximum number of idle dB connections to retain in pool.
Set to 0 for no limit.
-->
<parameter>
<name>maxIdle</name>
<value>5</value>
</parameter>
<!-- Maximum time to wait for a dB connection to become available
in ms, in this example 10 seconds. An Exception is thrown if
this timeout is exceeded. Set to -1 to wait indefinitely.
-->
<parameter>
<name>maxWait</name>
<value>10000</value>
</parameter>
<!-- MySQL dB username and password for dB connections -->
<parameter>
<name>username</name>
<value>test</value>
</parameter>
<parameter>
<name>password</name>
<value>testpwd</value>
</parameter>
<!-- Class name for mm.mysql JDBC driver -->
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
<!-- The JDBC connection url for connecting to your MySQL dB.
The autoReconnect=true argument to the url makes sure that the
mm.mysql JDBC Driver will automatically reconnect if mysqld closed the
connection. mysqld by default closes idle connections after 8 hours.
-->
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost/testdb?autoReconnect=true</value>
</parameter>
</ResourceParams>
</Context>
</Host>
</Engine>
</Service>
</Server>You haven't added a resource reference for your web application that gives the application a local name for the global resource "UserDatabase".
-
Errors when using tomcat and netbeans combo.[Solved]
Hi I'm trying to set up a netbeans/tomcat7 development environment for servlet development.
I have tried this on 2 machines without any success.
The steps I have followed are as follows.
First I installed tomcat7 and netbeans from using pacman, then to be able to configure tomcat from netbeans I made the config files write permission 777, as it's just a development server security is not an issue.
From there I started up netbeans started a new project and set the server to tomcat and pointed the Catalina home dir to /usr/share/tomcat7.
When I try to run the example jsp project I get the following error:
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: java.lang.IllegalStateException: No Java compiler available
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:584)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:392)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause
java.lang.IllegalStateException: No Java compiler available
org.apache.jasper.JspCompilationContext.createCompiler(JspCompilationContext.java:226)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:636)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:358)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
I've spent the last couple of days trying to find any information on this but I cant find anything, so any advice would be much appreciated.
Last edited by darkclown (2011-12-01 05:15:23)From the error, it appears that there is no JDK installed - only a JRE, could that be the case? If you do have a JDK installed, then Tomcat is not finding it.
I would also not run this on the openJDK, in case you are doing that. I would use the proprietary Oracle/Sun JDK. It's in the AUR, or simply download it from Oracle.
I was not even aware that netbeans and tomcat are available from pacman. I always "install" those myself manually (i.e. unpack them into a folder). They are simply Java apps that can be installed anywhere, as long as you point them to a valid JDK. -
Hello,
I deployed an BC4J/JSP webapplication to Tomcat using an MS SQL200 server as data-source. However, when running a jsp that queries the database the following error appears:
CustomerView1 Browse Form
Application Error
Error message: Only one of the two parameters target or targetParam should be defined.
Does anyone knows what this means?
Thanks...
HansHi,
Try the link http://otn.oracle.com/products/jdev/howtos/appservers/deploy_bc4j_to_jboss.html
Maybe this can help you. It runs JBoss with TomCat.
Hope this helps,
Rajat -
Error when using Tomcat and JavaWebStart
I got the following message:
========================================
An error occurred while launching/running the application.
Title: Notepad
Vendor: Sun Microsystems, Inc.
Category: Download Error
Bad MIME type returned from server when accessing resource: http://c152:8080/test.jnlp - text/plain
========================================
It worked fine for http://c152:8080/notepad.jnlp
Could any one help me?This got solved from a previous post by izhidov :
This person wrote:
"Regarding Tomcat and JNLP/MIME conflict, I've read on Tomcat users list archive that the mime types should be specified in the APPLICATION web.xml file under WEB-INF dir. Seems to work great".
Thanks. -
Where should JavaBeans be placed when using Tomcat?
I want to use a javaBean from inside a JSP, but it seems like Tomcat can't find the bean (...can't find the class).
Is there a particular catalogue where the bean-classes should be placed?
My test-JSP looks like this:
<html>
<head>
<title>Untitled</title>
</head>
<body>
<jsp: useBean id="enBean" class = "ASimpleBean"/>
</body>
</html>Your problem most probably is that your class isn't a member of a package. A recent change to the way java/tomcat works is that classes in the default package (ie no package) aren't visible any more.
Put your class in a package(eg SimplePackage), so your className would become simplePackage.ASimpleBean
The class files should be placed under your web-inf/classes directory on your web application.
Hope this helps,
evnafets -
Visibroker Bind Error When Using Sun Application Server
I have a servlet that utilizes Visibroker 3.4 to access CORBA objects. My servlet works fine when using Tomcat; however, when using the Sun Application Server 8.2 PE, the same code does not work. After a few second delay (timout?) then the following exception is thrown.
org.omg.CORBA.NO_IMPLEMENT:
Could not locate the following object:
repository id : IDL:A3Server:1.0
object name : mobile5A3Server
vmcid: 0x0 minor code: 0 completed: No
com.visigenic.vbroker.orb.ORB.bind(ORB.java:1282)
com.visigenic.vbroker.orb.ORB.bind(ORB.java:1361)
com.visigenic.vbroker.orb.ORB.bind(ORB.java:1171)
A3AppGen.A3ServerHelper.bind(A3ServerHelper.java:31)
A3AppGen.A3ServerHelper.bind(A3ServerHelper.java:27)
A3SessionConnection.connect(A3SessionConnection.java:74)
Has anyone experienced this and better, found the solution. Interesting fact is that this only occurs when using the .bind(orb(), serverName); call.
Another servlet packaged in the same .war file receives an IOR and is able to successfully access the CORBA object using orb().string_to_object(serverIOR); with both Tomcat and Sun Application Server.
Thanks for the help.Please list the content of 'asadminenv.conf'
Alternatively, you could just manually create the instance as follows:
asadmin.bat create-domain user admin adminport 4849 domaindir C:\Sun\AppServer\domains instanceport 8080 domain1 -
Tomcat error when using data source.
Hello,
I have a problem in that Tomcat does not seem to be recognising my DB Driver. I have tried linking a global data source to my application as well as adding a project specific one with no luck. Here is some of my files:
//Web.xml
<?xml version='1.0' encoding='UTF-8'?>
<web-app
version="2.4"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_4.xsd"
>
<display-name>DataSourceExample</display-name>
<servlet>
<display-name>welcome</display-name>
<servlet-name>welcome</servlet-name>
<jsp-file>/welcome.jsp</jsp-file>
</servlet>
<servlet>
<display-name>DataSourceExample</display-name>
<servlet-name>DataSourceExample</servlet-name>
<jsp-file>/DataSourceExample.jsp</jsp-file>
</servlet>
<welcome-file-list>
<welcome-file>welcome.jsp</welcome-file>
</welcome-file-list>
<resource-ref>
<res-ref-name>jdbc/DataSourceExample</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
</web-app>
//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
name="jdbc/DataSourceExample"
type="javax.sql.DataSource"
maxActive="4"
maxIdle="2"
username="hr"
maxWait="5000"
driverClassName="oracle.jdbc.driver.OracleDriver"
password="secret"
url="jdbc:oracle:thin:@127.0.0.1:1521:xe"/>
<Resource
auth="Container"
description="User database that can be updated and saved"
name="UserDatabase"
type="org.apache.catalina.UserDatabase"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml"/>
</GlobalNamingResources>
<Service
name="Catalina">
<Connector
port="8084"
redirectPort="8443"
minSpareThreads="25"
connectionTimeout="20000"
maxThreads="150"
maxSpareThreads="75">
</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">
<Context
path="/DataSourceExample"
<ResourceLink
global="jdbc/DataSourceExample"
name="jdbc/DataSourceExample"
type="javax.sql.DataSource"/>
</Context>
</Host>
</Engine>
</Service>
</Server>
//A java snippet I am using to access the DB
InitialContext context = new InitialContext();
DataSource dataSource =
(DataSource) context.lookup("java:comp/env/jdbc/DataSourceExample");
Connection conn = null;
Statement stmt = null;
ResultSet rset = null;
try {
conn = dataSource.getConnection();
stmt = conn.createStatement();I also have my DB drivers in the commons/lib file. I know the connect string works fine because I can access the DB from Eclipse when writing standard Java code.
This is a common problem and I have been searching Google for the last 3 hours but nothing I have tried has fixed my problem.
I am using Tomcat 5.5 and J2EE 5. I am creating the links and resources in Tomcat manager.
I don't get any logs or stacktrace, the only error I get is as follows in the returned JSP page:
DataSource Example
Cannot create JDBC driver of class '' for connect URL 'null'What am I doing wrong?
Cheers
EDIT:
Actually there was some output from the shell. Here it is:
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of cla
ss '' for connect URL 'null'
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDat
aSource.java:780)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSo
urce.java:540)
at org.apache.jsp.DataSourceExample_jsp._jspService(DataSourceExample_js
p.java:61)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
.java:332)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:3
14)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.p
rocessConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpo
int.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFol
lowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
ool.java:684)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.NullPointerException
at sun.jdbc.odbc.JdbcOdbcDriver.getProtocol(JdbcOdbcDriver.java:507)
at sun.jdbc.odbc.JdbcOdbcDriver.knownURL(JdbcOdbcDriver.java:476)
at sun.jdbc.odbc.JdbcOdbcDriver.acceptsURL(JdbcOdbcDriver.java:307)
at java.sql.DriverManager.getDriver(DriverManager.java:253)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDat
aSource.java:773)
... 22 more
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of cla
ss '' for connect URL 'null'
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDat
aSource.java:780)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSo
urce.java:540)
at org.apache.jsp.DataSourceExample_jsp._jspService(DataSourceExample_js
p.java:61)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
.java:332)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:3
14)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.p
rocessConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpo
int.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFol
lowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
ool.java:684)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.NullPointerException
at sun.jdbc.odbc.JdbcOdbcDriver.getProtocol(JdbcOdbcDriver.java:507)
at sun.jdbc.odbc.JdbcOdbcDriver.knownURL(JdbcOdbcDriver.java:476)
at sun.jdbc.odbc.JdbcOdbcDriver.acceptsURL(JdbcOdbcDriver.java:307)
at java.sql.DriverManager.getDriver(DriverManager.java:253)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDat
aSource.java:773)
... 22 moreI am using ojdbc14.jar driver and as I mentioned it is in commons/lib
Message was edited by:
helloWorld
Message was edited by:
helloWorldPutting the driver into [TOMCAT]/common/lib is sufficient.
The error I think is not related to finding the driver, but actually not retrieving the correct connection string info.
I never had much luck putting this definition info into server.xml
I have had success putting it into a custom context.xml file for a web app as described [url http://tomcat.apache.org/tomcat-5.5-doc/config/context.html]here
in individual files (with a ".xml" extension) in the $CATALINA_HOME/conf/[enginename]/[hostname]/ directory. The name of the file (less the .xml) extension will be used as the context path. Multi-level context paths may be defined using #, e.g. context#path.xml. The default web application may be defined by using a file called ROOT.xml.
eg [TOMCAT]/conf/catalina/localhost/DataSourceExample.xml
Hope this helps,
evnafets -
Exception when using RMI in tomcat 5.5, after reloading webapp
When I freshly start tomcat and deploy my web app, I can use RMI by creating a local registry and binding my objects.
However, as soon as I reload the web application, RMI no longer works and gives me this exception:
RMI error: error unmarshalling return; nested exception is:
java.io.EOFException
java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.io.EOFException
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at java.rmi.Naming.lookup(Naming.java:84)
at nl.heliotrope.tropebiz.tools.NutchRestarter.main(NutchRestarter.java:33)
Caused by: java.io.EOFException
at java.io.ObjectInputStream$BlockDataInputStream.peekByte(ObjectInputStream.java:2498)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1273)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348)
at sun.rmi.server.MarshalInputStream.readLocation(MarshalInputStream.java:285)
at sun.rmi.server.MarshalInputStream.resolveClass(MarshalInputStream.java:167)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1544)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1466)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1699)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348)
... 3 moreThe code to register my RMI object:
logger.debug("Setting up RMI");
//bind remote manager object to rmi resource
RemoteManager remoteManager = new RemoteManager();
try {
Naming.rebind(rmiResource, remoteManager);
} catch (MalformedURLException e) {
throw new RuntimeException("Cannot happen: " + e.getMessage());
} catch (RemoteException e) {
/* perhaps the registry was not started yet? Attempt.
* Cannot create registry automatically at web application startup,
* because another app may have done so already.
logger.debug("Error registering remote manager to RMI, " +
"service not running? Starting the registry.");
try {
LocateRegistry.createRegistry(1099);
Naming.rebind(rmiResource, remoteManager);
logger.debug("RMI Registry started and remote manager registered");
} catch (RemoteException e2) {
logger.error("Failed to start RMI registry or register RemoteManager!");
throw new RemoteException("rebind: " + e2.getMessage());
} catch (MalformedURLException e2) {
throw new RuntimeException("Cannot happen: " + e.getMessage());
logger.debug("RMI set up successfully");And client code:
IRemoteManager remoteManager = (IRemoteManager)Naming.lookup(RemoteManager
.getRMIResource("127.0.0.1", 1099));Trying set a RMISecurityManager breaks tomcat horribly by the way, but since RMI works with a fresh tomcat startup, I suppose there's no problems there.Hi all!
I get the same Exception using Tomcat 5.5. When registering an object outside tomcat lookup works fine. Only when registering an object inside a webapp!
Would be great if anyone got a tip to solve it!
Greetings... -
Tomcat does not work when using only netcfg to start network
hello!
for myself i wrote a script to connect automatically to a wireless network using netcfg. i do not start my network via the daemon (/etc/rc.d/network).
i have a project and so i want to use tomcat. but it does not work correct, i can start it, but i can't connect via "localhost:8080". when i start my network using the network daemon it works! apache runs fine, but i need tomcat!
can someone help me please?
thx, marvwhere is "lo" enabled in the network script? i did not found it and/or i have no idea which function enables it.
can you help me please? can i just copy the lines of code to my own script and it will enable lo?
mfg iggy -
Problem with Tomcat 4.1.24 when Using Servlets
hi
I am using tomcat webserver.. when I am making modifications in the servlets, everytime i am shutting down the tomcat server bcoz the servlet is not getting updated in the webserver.. can any one tell me the solution to dynamically update the servlets without shutting down the tomcat webserver each time i modify the servlets..
sanjayUse the Tomcat manager to install/remove the WAR file during development. That way you don't have to shutdown and startup the server:
http://kam02622:8080/index.jsp
Go into the manager app and you'll be able to see all the applications that are running.
Better yet, use the Catalina Ant tasks if you're using Ant as your build tool. I recommend this. - MOD -
Problem getting db connection when using virtual hosts / tomcat / apache
Hello,
I have servlets that use a connection pool to query an oracle database. When running Tomcat 5.5 stand-alone, everything works fine. But the same servlets do not work when running them on a server tomcat and apache integrated with jk and using virtual hosts. The problem is the connection pool, because servlets not using the pool also work fine.
Does anybody have any idea why this is happening?
Thank you.
LoganHi Saish,
Thank you for helping.
Try connecting with the machinen's IP, if this is a viable strategy for you (meaning the database IP is not dynamically assigned).I'm not sure how to do this. Here is a copy of my context.xml:
<Context path="" docBase="" debug="0">
<Resource name="jdbc/CraigsList" auth="Container"
type="javax.sql.DataSource" username="craigslist" password="xxxxxx"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@localhost:1521:GRI"
maxActive="8" maxIdle="4"/>
</Context>
Does this help?
Thanks. -
Problem when using Logger with Tomcat and eclipse
Hi, Iam using Tomcat 5.5.7 and my IDE is eclipse.Iam using java.util.logging.Logger class for logging.Iam putting the properties file in Appname/WEB-INF directory.The properties file is not identified.The error Iam getting is Error initialising log file java.lang.NullPointerException and java.io.FileNot FoundException
The content of my logging.properties file is
java.util.logging.ConsoleHandler java.util.logging.ConsoleHandler.level=SEVERE java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
java.util.logging.FileHandler.level=ALL java.util.logging.FileHandler.pattern=%h/javalogs%u.log java.util.logging.FileHandler.append=true java.util.logging.FileHandler.count=1
My servlet is
import java.io.*;
import java.util.logging.*;
import java.util.logging.Logger;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorldServlet extends HttpServlet
public void init(ServletConfig config) throws ServletException
try
String file=getServletConfig().getInitParameter("java.util.logging.config.file");
InputStream is = getServletContext().getResourceAsStream(file);
LogManager.getLogManager().reset();
LogManager.getLogManager().readConfiguration(is);
catch(Exception e)
System.out.println("Error initialising log file"+e);
public void doGet (HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException
final Logger fLogger =
Logger.getLogger(HelloWorldServlet.class.getName());
PrintWriter out;
String title = "Simple Servlet Output";
// set content type and other response header fields first
// then write the data of the response
response.setContentType("text/html");
fLogger.finest("this is finest");
fLogger.finer("this is finer");
fLogger.fine("this is fine");
fLogger.config("this is config");
fLogger.info("this is info");
fLogger.warning("this is a warning");
fLogger.severe("this is severe");
out = response.getWriter();
out.println("<P>This is output from SimpleServlet!!!!!!!!.");
}My web.xml file is
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<servlet>
<init-param>
<param-name>java.util.logging.config.file</param-name>
<param-value>/WEB-INF/classes/logging1.properties</param-value>
</init-param>
<servlet-name>HelloServlet</servlet-name>
<servlet-class>HelloWorldServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloServlet</servlet-name>
<url-pattern>/hello</url-pattern>
</servlet-mapping>
</web-app>Can anybody help me out.Hi, Iam using Tomcat 5.5.7 and my IDE is eclipse.Iam using java.util.logging.Logger class for logging.Iam putting the properties file in Appname/WEB-INF directory.The properties file is not identified.The error Iam getting is Error initialising log file java.lang.NullPointerException and java.io.FileNot FoundException
The content of my logging.properties file is
java.util.logging.ConsoleHandler java.util.logging.ConsoleHandler.level=SEVERE java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
java.util.logging.FileHandler.level=ALL java.util.logging.FileHandler.pattern=%h/javalogs%u.log java.util.logging.FileHandler.append=true java.util.logging.FileHandler.count=1
My servlet is
import java.io.*;
import java.util.logging.*;
import java.util.logging.Logger;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorldServlet extends HttpServlet
public void init(ServletConfig config) throws ServletException
try
String file=getServletConfig().getInitParameter("java.util.logging.config.file");
InputStream is = getServletContext().getResourceAsStream(file);
LogManager.getLogManager().reset();
LogManager.getLogManager().readConfiguration(is);
catch(Exception e)
System.out.println("Error initialising log file"+e);
public void doGet (HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException
final Logger fLogger =
Logger.getLogger(HelloWorldServlet.class.getName());
PrintWriter out;
String title = "Simple Servlet Output";
// set content type and other response header fields first
// then write the data of the response
response.setContentType("text/html");
fLogger.finest("this is finest");
fLogger.finer("this is finer");
fLogger.fine("this is fine");
fLogger.config("this is config");
fLogger.info("this is info");
fLogger.warning("this is a warning");
fLogger.severe("this is severe");
out = response.getWriter();
out.println("<P>This is output from SimpleServlet!!!!!!!!.");
}My web.xml file is
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<servlet>
<init-param>
<param-name>java.util.logging.config.file</param-name>
<param-value>/WEB-INF/classes/logging1.properties</param-value>
</init-param>
<servlet-name>HelloServlet</servlet-name>
<servlet-class>HelloWorldServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloServlet</servlet-name>
<url-pattern>/hello</url-pattern>
</servlet-mapping>
</web-app>Can anybody help me out. -
Viewing Excel Files using Tomcat - Problem with caching
Hi all,
A small part of an application I'm writing has links to Excel files for users to view/download. I'm currently using Tomcat v5 as the web/app server and have some very simple code (an example is shown below) which calls the excel file.
<%@ page contentType = "application/vnd.ms-excel" %>
<%
response.setHeader("Pragma", "no-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);
response.sendRedirect("file1.xls");
%>
This all works except but I'm having one big problem.
The xls file (file1.xls) is updated via a share on the server so each month, the xls file is overwritten with the same name but with different contents. I'm finding that when an update is made to the xls file and the user then attempts to view the new file in the browser they recieve only the old xls file. It's caching the xls file and I don't want it to. How can I fix this so that it automatically gives the user the new updated file.
The only way I've managed to get Tomcat to do this is to delete the work directory and delete the file from my IE temp folder and then restart Tomcat - this is a bit much!
Any help would be greatly appreciated.
Thanks.I'd a problem with caching a few years back, for a servlet request which returned an SVG file.
As a workaround, I ended up putting appending "#" and a timestamp / random number after it. The browser assuming each request was new, and didn't use the cache.
Eg.
http://myserver/returnSVG.do#1234567
where 1234567 is a timestamp / random.
Not sure whether you can do this on a file based URL... but maybe worth a shot...
regards,
Owen -
Problem setting Unicode (utf-8) in http header using tomcat
Hi:
I am trying to set a file name in utf-8 to http header using the following code:
response.setContentType("text/html; charset=utf-8");
response.setHeader("Content-disposition", "attachment; filename=解決.zip");
// I actually has file name in utf-8 here to set to the header, and I know that the name is correctly
// and I also looked into the response object MimeHeaders object and saw the head is correctly there
then write the content of zip file using ServletOutputStream.
The problem I have is that the file name is not displayed correctly when prompted to save or open in the pop up window next. I found out using Fiddler that the request header is wrong:
Content-disposition: attachment; filename=�zn��.zip
I am using Tomcat 5.0.28. Any idea how to get this working?
Thanks in advance!You are setting the charset for the content to be UTF-8. (That is why the method is called setContentType.) But HTTP headers are not part of the content and so that has no effect on the header.
The original specification for HTTP only allowed US-ASCII characters in headers. It is possible that more recent versions have features that allow for non-ASCII header data, but I don't know if that is the case or how you would use those features if they exist.
Maybe you are looking for
-
My command key on my macbook pro retina 2014 is sinking
So I have recently bought a Macbook pro retina 13 inch 2014 model. I have been using it a lot lately especially for typing and using the command key. I notice that my left command key is sinking or in other words, the left command key is much lower o
-
Unable to create cofile from data file
Hi All, I am trying to create a cofile with the commane **** tp createcofile <TR>**** and getting the following error ..... ---> tp CREATECOFILE DC1K900012 pf=/usr/sap/trans/bin/TP_DOMAIN_DC1.PFL This is tp version 372.04.65 (release 701, unicode ena
-
Will a US bought Macbook work in the UK?
Would a US Macbook still be able to connect to UK printers and Wi-Fi routers?
-
we have an assignment for class to find 3 examples of interactive pdf documents on the web everytime i put the info in it comes up with how to do it or create it i just need 3 links to show examples in class please somebody tell me how to search for
-
Dear Friends! I have one requirement, I have to trigger Unix Shell script from ABAP program. but only twist in the story is my SAP box is not in Unix system so I cant use external command execute function module. Is any one come accross t