Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Problem with multiple images in a JSP (Connection reset by peer)

843835Sep 5 2002 — edited Sep 5 2002
Hi,
I have a JSP page that calls a servlet to create image thumbnails. I am also using javascript, because once those thumbnails are loaded the user can click on any one of them to see the full picture (once again the full image will be produced by the servlet).
So, I have a lot of the following lines :
document.write('<img border="0" src="../servlet/DisplayXwd?pic=img1&size=thumb" onclick="displayPic(img1)">');

document.write('<img border="0" src="../servlet/DisplayXwd?pic=img2&size=thumb" onclick="displayPic(img2)">');
... and so on.

I have about 30 thumbnails to display. Now, when I open up only one browser most of the time these thumbnails appear correctly. But, the problem usually happens when I have more than one browser open requesting the same page, then some of the thumbnails appear as broken links.

On the servlet side I am using ImageIO to send each BufferedImage across like this:
            res.setContentType("image/jpeg"); 
            ServletOutputStream sos = res.getOutputStream();
            ImageIO.write(bImg,"JPEG",sos); 
            sos.flush();
            sos.close();
My Tomcat 4 server shows that I am getting a "SocketException: Connection Reset by Peer" Exception. I dont really understand why that connection would be interrupted for only a few of the images on the page, while the rest load fine.
Could somebody please help me find the error or suggest an alternative method.

Thanks a lot,
Val.

p.s. I am thinking about using an applet instead of mine JSP page with HTML frames to display the thumbnails, but then again BufferedImages are not serializable, so I'll have to figure out a way send them to the applet.

p.p.s. Here is the full Exception thread from the Tomcat log:

2002-09-05 11:53:50 StandardWrapperValve[DisplayXwd]: Servlet.service() for servlet DisplayXwd threw exception
java.net.SocketException: Connection reset by peer: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:126)
at org.apache.catalina.connector.ResponseBase.flushBuffer(ResponseBase.java:679)
at org.apache.catalina.connector.HttpResponseBase.flushBuffer(HttpResponseBase.java:757)
at org.apache.catalina.connector.ResponseBase.write(ResponseBase.java:652)
at org.apache.catalina.connector.ResponseStream.write(ResponseStream.java:312)
at org.apache.catalina.connector.http.HttpResponseStream.write(HttpResponseStream.java:182)
at javax.imageio.stream.FileCacheImageOutputStream.flushBefore(FileCacheImageOutputStream.java:209)
at javax.imageio.stream.ImageInputStreamImpl.flush(ImageInputStreamImpl.java:801)
at com.sun.imageio.plugins.jpeg.JPEGImageWriter.write(JPEGImageWriter.java:957)
at javax.imageio.ImageWriter.write(ImageWriter.java:591)
at javax.imageio.ImageIO.write(ImageIO.java:1365)
at javax.imageio.ImageIO.write(ImageIO.java:1439)
at net.progeny.tools.imageViewer.servlet.DisplayXwd.processRequest(DisplayXwd.java:82)
at net.progeny.tools.imageViewer.servlet.DisplayXwd.service(DisplayXwd.java:108)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2343)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1012)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1107)
at java.lang.Thread.run(Thread.java:536)

Comments

843833
For using J2EE I installed Eclipse 3.0.1,
j2sdk1.4.2_07, Sun Java System Application Server
Platform Edition 8.1 and J2EE 1.4 SDK Samples and I
add the path for J2EE in Eclipse by navigating
Window -> Preferences -> Java -> Build Path ->
Classpath Variables and adding J2EE_HOME
d:\Progs\Sun\AppServer.
Add j2ee.jar from from %J2EE_HOME%\lib as an external JAR to the project. It should not have any qualms compiling then. :-)
843833
Hi,

I don't know how I can compile my servlet in Eclipse. Calling Run on the project opens a window where I can create new configurations for a Java Applet, a Java application or a wireless Toolkit Emulator, but no possibility to run a Java servlet.

How do you compile a Java servlet in Eclipse?

From desperation I tried to compile my servlet in Windows console by calling but I get the messages that the packages I need do not exist:

D:\Progs\eclipse\WorkspaceServlets> javac -classpath %J2EE_HOME%\lib\j2ee.jar Ch05\eb\Login.java
Ch05\web\Login.java:9: package javax.servlet.http does not exist
import javax.servlet.hhtp.*;
and so on

What's the matter?

I only found out that I have no j2sdkee1.4 directory because I did not installed the J2EE All-In-One-Bundle because I had J2SE 1.4.02 installed. Instead of it I only installed the Sun Java System Application Server Platform Edition 8.1. I did not install the J2EE 1.4 Platform API Documentation but I think that's not necessary because it is only a documentation.

What do I wrong?

Best regards,
Anjuli
843833
i am putting source code in eclipse , in that one servlet is there but eclipse but when i am running that code servlet is not resolving.
843833
I am trying to build a project in Eclipse 3.1. I installed j2sdk1.4.2_09. I am getting the following error:
"The project was not built since its build path is incomplete. Cannot find the class file for javax.servlet.ServletRequest. Fix the build path then try building this project"
My j2sdk1.4.2_09 is installed in my C:drive. I added the following to the classpath in Eclipse
JAVA_HOME
C:/j2sdk1.4.2_09
Why am I still getting the javax.servlet error?
843833
You can use an external Ant file to build all your project, as:
ant -projecthelp
ant compile
ant build
ant deploy

Below you can find an example:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%
<project name="DTAC" default="compile" basedir=".">


<!-- ===================== Property Definitions =========================== -->

<!--
All properties should be defined in this section.
Any host-specific properties should be defined
in the build.properties file.

In this app, the following properties are defined in build.properties:

o tomcat.home - the home directory of your Tomcat installation
o webapps.home - the place to copy the war file to deploy it
-->

<!-- <property file="build.properties" /> -->

<property name="app.home" value="." />
<property name="app.name" value="dtac" />
<property name="tomcat.home" value="C:\apache-tomcat-6.0.14"/>
<property name="webapps.home" value="C:\apache-tomcat-6.0.14\webapps"/>

<property name="src.home" value="${app.home}/src"/>
<property name="lib.home" value="${app.home}/lib"/>
<property name="deploy.home" value="${app.home}/deploy"/>
<property name="object.home" value="${app.home}/object"/>
<property name="doc.home" value="${app.home}/doc"/>
<property name="web.home" value="${app.home}/WebContent"/>

<property name="build.home" value="${app.home}/build"/>
<property name="build.classes" value="${build.home}/WEB-INF/classes"/>
<property name="build.lib" value="${build.home}/WEB-INF/lib"/>

<property name="src" location="src" />
<property name="classes" location="classes" />
<property name="include" location="classes" />



<!-- ==================== Compilation Classpath =========================== -->

<!--
This section creates the classpath for compilation.
-->

<path id="compile.classpath">

<!-- The object files for this application -->
<pathelement location="${object.home}"/>


<!-- The lib files for this application -->
<fileset dir="${lib.home}">
<include name="*.jar"/>
<include name="*.zip"/>
</fileset>

<!-- All files/jars that Tomcat makes available -->
<!--fileset dir="${tomcat.home}/common/lib">
<include name="*.jar"/>
<include name="*.zip"/>
</fileset>-->
<pathelement location="${tomcat.home}/classes"/>
<!--<pathelement location="${tomcat.home}/common/classes"/>-->

</path>


<!-- ==================== Build Targets below here========================= -->


<!-- ==================== "help" Target =================================== -->

<!--
This is the default ant target executed if no target is specified.
This helps avoid users just typeing 'ant' and running a
default target that may not do what they are anticipating...
-->

<target name="help" >
<echo message=" Favor de especificar un target! [uso: ant <targetname>]" />
<echo message=" List de posibles targets: "/>
<echo message=" clean-all.....Delete build dir, all .class and war files"/>
<echo message=" prepare.......Creates directories if required" />
<echo message=" compile.......Compiles source files" />
<echo message=" build.........Build war file from .class and other files"/>
<echo message=" deploy........Copy the app and Axis war files to Tomcat" />
<echo message=" javadoc.......Generates javadoc for this application" />
</target>

<!-- ==================== "clean-all" Target ============================== -->

<!--
This target should clean up any traces of the application
so that if you run a new build directly after cleaning, all
files will be replaced with what's current in source control
-->

<target name="clean-all" >
<delete dir="${build.home}"/>
<delete dir="${object.home}"/>
<delete dir="${deploy.home}"/>

<!-- can't delete directory if Tomcat is running -->
<delete dir="${webapps.home}/${app.name}"/>

<!-- deleting the deployed .war file is fine even if Tomcat is running -->
<delete dir="${webapps.home}/${app.name}.war" />

<!-- delete the javadoc -->
<delete dir="${doc.home}"/>

<!-- delete all the class files from the source dir -->
<delete>
<fileset dir="${src.home}" includes="**/*.class"/>
</delete>

<!-- Note that the clean target doesn't delete the Axis server webapp -->
<!-- This is since other apps may be using it - add it here if needed -->

</target>

<!-- ==================== "prepare" Target ================================ -->

<!--
This target is executed prior to any of the later targets
to make sure the directories exist. It only creates them
if they need to be created....

Other, similar, preparation steps can be placed here.
-->

<target name="prepare">

<echo message="Tomcat Home = ${tomcat.home}" />
<echo message="webapps Home = ${webapps.home}" />

<mkdir dir="${object.home}"/>
<mkdir dir="${deploy.home}"/>

<mkdir dir="${doc.home}"/>
<mkdir dir="${doc.home}/api"/>

<mkdir dir="${build.home}"/>
<mkdir dir="${build.home}/WEB-INF" />
<mkdir dir="${build.home}/WEB-INF/classes"/>
<mkdir dir="${build.home}/WEB-INF/lib" />

</target>

<!-- ==================== "compile" Target ================================ -->

<!--
This only compiles java files that are newer
than their corresponding .class files.
-->

<target name="compile" depends="prepare" >
<javac srcdir="${src.home}" destdir="${object.home}" debug="yes" >
<classpath refid="compile.classpath"/>
</javac>

<!--
Copy the .class files to source tree. The Java2WSDL utility
needs these to generate the WSDL and Value Object Java files.
-->

<copy todir="${src.home}">
<fileset dir="${object.home}"/>
</copy>

</target>

<!-- ==================== "build" Target ================================== -->

<!--
This target builds the war file for the application
by first building the directory structure of the
application in ${build.home} and then creating the
war file using the ant <war> task
-->

<target name="build" depends="compile" >

<!-- Copy all the webapp content (jsp's, html, tld's, xml, etc. -->
<!-- Note that this also copies the META-INF directory -->
<copy todir="${build.home}">
<fileset dir="${web.home}"/>
</copy>

<!-- Now, copy all the Java class files -->
<copy todir="${build.home}/WEB-INF/classes">
<fileset dir="${object.home}"/>
</copy>

<!-- Now, copy all the properties files, etc that go on the classpath -->
<copy todir="${build.home}/WEB-INF/classes">
<fileset dir="${src.home}">
<include name="**/*.properties" />
<include name="**/*.prop" />
</fileset>
</copy>

<!-- Now, copy all the jar files we need -->
<copy todir="${build.home}/WEB-INF/lib">
<fileset dir="${lib.home}" />
</copy>

<!-- Create the <war> file -->
<jar jarfile="${deploy.home}/${app.name}.war"
basedir="${build.home}"/>

</target>



<!-- ==================== "deploy" Target ================================= -->

<!--
This target simply copies the war file from the deploy
directory into the Tomcat webapp directory.
This version of the file makes sure our files are
deployed into the Axis server webapp as well.

Note that deploying our files into the Axis webapp isn't
enoigh. In addition, there is a 'deploy' step required
to register the web service with Axis. Details are
provided in the chapter text.
-->

<target name="deploy" depends="build" >

<!-- Copy the contents of the build directory -->
<copy todir="${webapps.home}" file="${deploy.home}/${app.name}.war" />

</target>


<!-- ==================== "doc" Target ==================================== -->

<!--
This task creates javadoc. It is dependent upon only the
'compile' target so it is not executed in a normal build.
As a result, the target needs to be run on its own.
-->

<target name="javadoc" depends="compile">
<javadoc sourcepath = "${src.home}"
destdir = "${doc.home}/api"
packagenames = "${javadoc.pkg.top}.*"/>
</target>


</project>
843833
Hey Anjuli,
It's Amit from Delhi(India), I am working as a freelance developer using servlet and jsp. Regarding to your problem I would be happy to suggests you that you might need to set path and classpath for j2sdk. I am giving the path details for windows.
Right click on My Computer>Properties>Advance>Enviroment Variables:
On the top you will get User Variable parts>Click New Variable, named this as CLASSPATH from user variable and write following things:::%classpath%;c:\j2sdk1.4.2_08\lib;;c:\sun\appserver\lib\j2ee.jar;; in value part.
Save this.
On the bottom side you will get System Variable>Click on New Variable>Named this as JAVA_HOME, Write in value c:\j2sdk1.4.2_08
Save this
Create another new variable>Named this as J2EE_HOME>Write c:\sun\appserver;
Save this.
Select path from system variables>Click on Edit>Write c:\j2sdk1.4.2_08\bin;;c:\sun\appserver\bin;;
Save this.
Click on APPLY>Click on OK.
Close the window
Close the COMMAND PROMPT>>
Open another command prompt>>Compile the program written in java language.
Write javac filename with .java extension.>>Press enter>
You might get your solution by following these steps, Still having problem Call me on my mobile-"08010612406".
I would be happy to solve your problem..... Thanking you.
darrylburke
Locking zombie thread, blocking self-advertising post.

db
1 - 7
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Oct 3 2002
Added on Sep 5 2002
1 comment
358 views