Testing servlet using Web2Go
I am trying to test several servlets by registering the servelts to the Web Object Managers. After registering the servlets, I still cannot run the servlets. I can only run one at a time using "http://localhost:7070/servlets/servlet".
Likewise, I named my servlets differently, eg. test01, test02, test03, etc. However, I cannot called it usnig the "http://localhost:7070/servlets/test01" as I thought it should after I register the servlets to the Web Object Manager.
Is there anyway to look at the mapping of the Web2Go properties file? Where is it located? Is there a special setup to make the Web Object Manager to work properly?
Any help will be greatful.
The web object manger manipulates a file called wtgapp.xml. Webtogo looks for it jdev's lib directory (ie C:\jdev\lib). Unfortunately in jdev 3.1, the web object manager looks for it in the directory above (ie c:\jdev). You can get around the problem by copying it into the lib directory after you finish registration in the web object manager
Similar Messages
-
How to test servlet using Junit test????
Hello everybody
Does anybody know how to test an servlet class using Junit without using Cactus test . Is it possible to test a servlet using Junit without cactus test.Plz tell me the process how to test a servlet using Junit test .
Regards
srikant1) Do yoiu mean how to "run" your servlet code with sample parameter? This call manual testing with a sample run of you code. You need a web server(eg Tomcat), create a webapp with your servlet then deploy it there in order to run it.
2) httpunit and junit are framework to write test case code that can be automated and repeatable. Plz read their doc.
3) Your sample code me a very wrong way to retrieve and convert servlet parameters.
Get a java toturial and servlet tutorial book and read it over the weekend. You need to get at least the basic. -
Can not run the test form using servlet (patch 8)
Installed 9I AS 1.0.2.2.1 and forms patch 8 on Windows 2000.
Configured the Forms Listener Servlet by following the white paper "Forms 6i Patch 8: Oracle Forms Listener Servlet for Deployment of Forms on the Internet".
I can get the page titled Forms 6i Listener Servlet using URL: http://myserver/servlet/oracle.forms.servlet.ListenerServlet.
However, I can not run the test form using the servlet by the url:
http://myserver/servlet/f60servlet?config=servlet. In the formsweb.cfg file I also added a section
[servlet]
serverURL=/servlet/oracle.forms/servlet.ListenerServlet
No meaningful error message. At first it seems very slow, and then shows the "The page can not be displayed" page.
Please advise.
Thanks.u must add "Script Alias ifcgi60 "$ORACLE_HOME/forms60/cgi" in confirguration.
-
How to send a String to a Servlet using a HTTP POST
Well, I have designed a servlet that receives a HTTP POST, I was testing it using an HTML form to send (using POST) information, now, I have coded a Java App to send it a string, I don't know how to make the servlet recognize that info so it can make its work, I am posting both codes (Servlet & API) so anyone can guide me and tell me how and where to modify them
Servlet:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.sql.*;
public class xmlwriter extends HttpServlet
public void service(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
ServletOutputStream salida = res.getOutputStream();
res.setContentType("text/HTML");
String cadena = req.getParameter("cadena");
File f1 = new File ("c:/salida.xml");
FileWriter out = new FileWriter(f1);
f1.createNewFile();
out.write(cadena);
out.close();
salida.println("OK");
Now, the JAVA API is:
import java.io.*;
import java.net.*;
public class HTTPSender {
public static void main(String[] args) throws Exception {
URL url1 = new URL
("http://localhost:8080/XMLSender/xmlwriter");//internal site
URLConnection UrlConnObj1 = url1.openConnection();
HttpURLConnection huc1 = (HttpURLConnection)UrlConnObj1;
huc1.setRequestMethod("POST");
huc1.setDoOutput(true);
huc1.setDoInput(true);
huc1.setUseCaches(false);
huc1.setDefaultUseCaches(false);
String cadena = ""
+ "<root>\n"
+ "<tlf>$TLF$</tlf>\n"
+ "<op>$OP$</op>\n"
+ "<sc>$SC$</sc>\n"
+ "<body>$BODY$</body>\n"
+ "</root>";
PrintWriter out = new PrintWriter(huc1.getOutputStream());
System.out.println("string="+cadena);
out.write(cadena);
out.close();
I'm a JAVA newbie, so, maybe I'm getting a bad idea of what I need to do, anyway, every (detailed) help is welcome. What my servlet should do (and it doesn't when I send the message through the API) is to write a file with the info received.I'm not trying to send a string from a WEB Page, I'm tryring to send it using a JAVA program, I mean, using a HTTPSender, in fact, I already have made the code to do that:
import java.io.*;
import java.net.*;
public class HTTPSender {
public static void main(String[] args) throws Exception {
try {
String cadena = "Message to be written";
// Send data
URL url = new URL("http://localhost:8080/XMLSender/xmlwriter");
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write(cadena);
wr.flush();
// Get the response
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while ((line = rd.readLine()) != null) {
// Process line...
wr.close();
rd.close();
} catch (Exception e) {
And modified my servlet so it can receive anything:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.sql.*;
public class xmlwriter extends HttpServlet
public void service(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
ServletOutputStream salida = res.getOutputStream();
res.setContentType("text/HTML");
String cadena = req.toString();
File f1 = new File ("c:/salida.xml");
FileWriter out = new FileWriter(f1);
f1.createNewFile();
out.write(cadena);
out.close();
salida.println("OK");
Now the problem is that, the servlet in fact DOES create the file, but....the file is empty, that means that no info is arriving to the servlet, why?, how should I send it then? I repeat FORGET about a Web Page Form, that is in the past and I don't need that. -
Communication with servlet using HTTPURLConnection
Hi Again,
well..trying to connect to a servlet using the HTTPURLConnection class.
but the servlet is found (as i have put a system.out in init method of the servlet and that gets printed correctly).my problem is that the doget method does not get invoked.
following is the code:
client side:
public class test
public test()
ObjectOutputStream outs=null;
try
URL url = new URL("http://127.0.0.1:7001/DataFetchServlet");
HttpURLConnection urlcon = (HttpURLConnection)url.openConnection();
System.out.println(urlcon.toString());
urlcon.setRequestProperty("Content-Type","application/octet-stream");
urlcon.setRequestMethod("GET");
urlcon.setDoInput(true);
urlcon.setDoOutput(true);
urlcon.setUseCaches(true);
outs = new ObjectOutputStream(urlcon.getOutputStream());
String str = new String("hello");
outs.writeObject(str);
ObjectInputStream inp = new ObjectInputStream (urlcon.getInputStream());//********************
outs.flush();
outs.close();
catch(Exception e)
e.printStackTrace();
//******************** THIS LINE GIVES A FILENOTFOUND EXCEPTION
I am sure the servlet is found before the object is written but after the getInputStream it throws the excpetion..
can anyone help?????
THanx in advanceurlcon.connect();
-
Error encountered while running a test case using MTM
Hello,
Has anyone encountered this error while running a test case using MTM 2013?
When I click on OK, the message is again shown until that time wherein the popup error is no longer shown.
When I try to continue to the next pages wherein a modal is being open and I need to enter some data on a text field, the IE would stop working and seems to crash.
Thanks!Hi Kiyaruh,
Base on the error message, the error is threw by internet explorer.
Does it have the same issue when access that web site/page in IE directly or it just occurs when run tests through MTM?
What’s the version of your browser? You may try it with other browser and check whether it has same issue.
Regards
Starain
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Unable to deploy a simple servlet using WAR file on Oracle9iAS v9.0.3
Hi All,
I am facing problem while deploying a simple servlet using WAR file on Oracle 9i App Server.
I have installed Oracle9iAS J2EE and Web Cache v9.0.3 on Windows 2000 server.
It includes:
- Oracle HTTP Server
- Oracle9iAS Containers for J2EE
- Oracle9iAS Web Cache
- Oracle Enterprise Manager
The release of installed Oracle9iAS is Release 2 (9.0.3)
I referred following link to Deploy Applications Using WAR file:
http://otn.oracle.com/products/ias/daily/sept12.html
As mentioned in this documentation I have followed following steps to deploy WAR file:
1] I have created a war file by name SimpleServlet.war. In SimpleServlet.war, there is a servlet by name Simple which prints time at which servlet was accessed.
2] I have modified <ora9ias_home>\j2ee\home\config\application.xml and added following web module entry:
<web-module id="SimpleServlet" path="../../home/applications/SimpleServlet.war" />
3] To make this module accessible from over the web, I have modified file
<ora9ias_home>\j2ee\home\config\default-web-site.xml and added following entry:
<web-app application="SimpleServlet" name="SimpleServlet" root="/SimpleServlet"/>
4] I saved both the files and started Oracle HTTP Server and accessed page as below:
http://<server>:7777/SimpleServlet/Simple
where Simple is servlet in SimpleServlet.war file.
In the browser, The page cannot be found is shown to user. I have verified that SimpleServlet.war is extracted to SimpleServlet folder under <ora9ias_home>\j2ee\home\applications folder. I found that Simple.class is stored under WEB-INF/classes folder and web.xml contains correct entry for url pattern for servlet Simple.
What else could be the problem? Am I placing the war file in wrong place or modifying application.xml or default-web-site.xml in a wrong directory?
This is very urgent. Please help me with your valuable comments on this.
Thanks in advance.
Regards,
SandeshHi All,
I am facing problem while deploying a simple servlet
using WAR file on Oracle 9i App Server.
I have installed Oracle9iAS J2EE and Web Cache v9.0.3
on Windows 2000 server.
It includes:
- Oracle HTTP Server
- Oracle9iAS Containers for J2EE
- Oracle9iAS Web Cache
- Oracle Enterprise Manager
The release of installed Oracle9iAS is Release 2
(9.0.3)
I referred following link to Deploy Applications
Using WAR file:
http://otn.oracle.com/products/ias/daily/sept12.html
As mentioned in this documentation I have followed
following steps to deploy WAR file:
1] I have created a war file by name
SimpleServlet.war. In SimpleServlet.war, there is a
servlet by name Simple which prints time at which
servlet was accessed.
2] I have modified
<ora9ias_home>\j2ee\home\config\application.xml and
added following web module entry:
<web-module id="SimpleServlet"
path="../../home/applications/SimpleServlet.war" />
3] To make this module accessible from over the web,
I have modified file
<ora9ias_home>\j2ee\home\config\default-web-site.xml
and added following entry:
<web-app application="SimpleServlet"
name="SimpleServlet" root="/SimpleServlet"/>
4] I saved both the files and started Oracle HTTP
Server and accessed page as below:
http://<server>:7777/SimpleServlet/Simple
where Simple is servlet in SimpleServlet.war file.
In the browser, The page cannot be found is shown to
user. I have verified that SimpleServlet.war is
extracted to SimpleServlet folder under
<ora9ias_home>\j2ee\home\applications folder. I found
that Simple.class is stored under WEB-INF/classes
folder and web.xml contains correct entry for url
pattern for servlet Simple.
What else could be the problem? Am I placing the war
file in wrong place or modifying application.xml or
default-web-site.xml in a wrong directory?
This is very urgent. Please help me with your
valuable comments on this.
Thanks in advance.
Regards,
SandeshHave you restarted you http server and then tried to load it again? Are you using the right port; maybe you have to use port 7778? Check you server settings in the http server instance. Also check your url binding of you application at Farm > Application Server: infrastructurehost > OC4J_instance > Application: appname > Web Module: modulename
Good luck!
rgds Thomas -
Unable to deploy a simple servlet using WAR file
Hi All,
I am facing problem while deploying a simple servlet using WAR file on Oracle 9i App Server.
I have installed Oracle 9i App Server. I referred following link to Deploy Applications Using WAR file:
http://otn.oracle.com/products/ias/daily/sept12.html
As mentioned in this documentation I have followed following steps to deploy WAR file:
1] I have created a war file by name SimpleServlet.war. In SimpleServlet.war, there is a servlet by name Simple which prints time at which servlet was accessed.
2] I have modified <ora9ias_home>\j2ee\home\config\application.xml and added following web module entry:
<web-module id="SimpleServlet" path="../../home/applications/SimpleServlet.war" />
3] To make this module accessible from over the web, I have modified file
<ora9ias_home>\j2ee\home\config\default-web-site.xml and added following entry:
<web-app application="SimpleServlet" name="SimpleServlet" root="/SimpleServlet"/>
4] I saved both the files and started Oracle HTTP Server and accessed page as below:
http://<server>:7777/SimpleServlet/Simple
where Simple is servlet in SimpleServlet.war file.
In the browser, The page cannot be found is shown to user. I have verified that SimpleServlet.war is extracted to SimpleServlet folder under <ora9ias_home>\j2ee\home\applications folder. I found that Simple.class is stored under WEB-INF/classes folder and web.xml contains correct entry for url pattern for servlet Simple.
What else could be the problem? Am I placing the war file in wrong place or modfiying application.xml or default-web-site.xml in a wrong directory?
This is very urgent. Please help me with your valuable comments on this.
Thanks in advance.
Regards,
SandeshHi Juliana,
Thanks a lot for your suggestion.
I am sorry if I have posted this message to a wrong forum. This is first time I am posting a message to OTN. I will resend message to J2EE forum as per you suggestion.
Meanwhile, please note information you asked for is as below:
I installed Oracle9iAS J2EE and Web Cache v9.0.3 on Windows 2000 server.
It includes:
- Oracle HTTP Server
- Oracle9iAS Containers for J2EE
- Oracle9iAS Web Cache
- Oracle Enterprise Manager
The release of installed Oracle9iAS is Release 2 (9.0.3)
Please do reply at the earliest.
Once again thanks and look forward to hear from you.
Regards,
Sandesh -
Revision: 17772
Revision: 17772
Author: [email protected]
Date: 2010-09-20 15:02:50 -0700 (Mon, 20 Sep 2010)
Log Message:
Update the url in the tests to use a relative path instead of the default localhost:8400 so that the tests can pass on appservers other than the default Tomcat.
Modified Paths:
blazeds/trunk/qa/apps/qa-regress/testsuites/config/tests/EnforceEndpointValidation/Enforc eEndpointValidationFalseTest/Remoting_NetConnectionTest.mxml
blazeds/trunk/qa/apps/qa-regress/testsuites/config/tests/EnforceEndpointValidation/Enforc eEndpointValidationTrueTest/Remoting_NetConnectionTest.mxmlRevision: 17772
Revision: 17772
Author: [email protected]
Date: 2010-09-20 15:02:50 -0700 (Mon, 20 Sep 2010)
Log Message:
Update the url in the tests to use a relative path instead of the default localhost:8400 so that the tests can pass on appservers other than the default Tomcat.
Modified Paths:
blazeds/trunk/qa/apps/qa-regress/testsuites/config/tests/EnforceEndpointValidation/Enforc eEndpointValidationFalseTest/Remoting_NetConnectionTest.mxml
blazeds/trunk/qa/apps/qa-regress/testsuites/config/tests/EnforceEndpointValidation/Enforc eEndpointValidationTrueTest/Remoting_NetConnectionTest.mxml -
Unit Test code using wrong persistence unit
In the midst of learning Maven, I created a simple application in which I am using JPA (Java Persistence 1.0.2) with EclipseLink implementation (2.0.2).
Note: This is an Application Managed environment. So I manually control EntityManager's life cycle.
The persistence.xml file used by the main source code is different from the one that unit test code uses. Main code uses an Oracle DB and the test code uses an in-memory Derby.
Running unit tests was updating the Oracle DB (!) and I eventually managed to fix that by using two different persistence-units in the XML files.
However, I don't understand why that fixed the problem. I manually create and shut down the entity managers and they are not running concurrently. I'm pretty sure Maven (or the way I set it up) doesn't mess up the resources (XML files). In fact by looking at Maven's debug output I can see it's using the right XML file for unit tests.
Could someone enlighten me, please?Do you have both persistence.xml files on your classpath? If so, and they contain the same name for their respective persistence units, you should be getting a warning or error since they must have unique names. There is no way to tell which one you want to access otherwise.
Best Regards,
Chris -
Connecting a servlet using a midlet
Hi,
I am trying to connect to a servlet using a Midlet. The servlet is running fine on Apache Tomcat and I m able to build the MIDlet using J2MEWTK . But when I execute the Midlet on an emulator it shows me some code of html page of which the important line which might give u some hint is :
the requested resource (/hitservlet) is not available.
I wrote the code of HitServlet and Hitmidlet using a pdf on net....Do I need to install something else for executing this? I dont understand where is the problem. Should I post the codes? Is it something related to aliases...as indicated by some some tutorial...if so plss elaborate on it..
If anybdy has any idea ...plss help me get out of this problem...
Thanx
SmeetaHave you added the URL of the Servlet into the J2ME application?
Settings -> UserDefined Tab
Thinks its
HitMIDlet.URL and its value should be the URL of the Servlet -
Problem running servlet using PJA tools
Hi
I am trying to run the TeksSurveyPie servlet from the PJA Package.But everytime i run it says
Internal error: Unexpected error condition thrown (java.lang.NoClassDefFoundError: TeksSurveyPie (wrong name: com/eteks/servlet/TeksSurveyPie),TeksSurveyPie (wrong name: com/eteks/servlet/TeksSurveyPie)), stack: java.lang.NoClassDefFoundError: TeksSurveyPie (wrong name: com/eteks/servlet/TeksSurveyPie)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:495)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:110)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
at java.net.URLClassLoader.access$1(URLClassLoader.java:217)
at java.net.URLClassLoader$1.run(URLClassLoader.java:198)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:192)
at java.lang.ClassLoader.loadClass(ClassLoader.java:300)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:290)
at java.lang.ClassLoader.loadClass(ClassLoader.java:256)
at java.lang.ClassLoader.findSystemClass(ClassLoader.java:629)
at com.iplanet.server.http.servlet.NSServletLoader.findClass(NSServletLoader.java:152)
at com.iplanet.server.http.servlet.NSServletLoader.loadClass(NSServletLoader.java:108)
at com.iplanet.server.http.servlet.NSServletEntity.load(NSServletEntity.java:337)
at com.iplanet.server.http.servlet.NSServletEntity.update(NSServletEntity.java:173)
at com.iplanet.server.http.servlet.NSServletRunner.Service(NSServletRunner.java:427)
I am tryin to access the servlet like this
https://avenger/servlet/TeksSurveyPie?survey=Yes
Pls tell me where i am going wrong...????Its preety urgent ....
thanks
prabhuthe servlet is as below for reference .....
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import javax.servlet.ServletConfig;
import javax.servlet.UnavailableException;
import java.io.IOException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.Properties;
import java.util.Vector;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.StringTokenizer;
import java.awt.Graphics;
import java.awt.Color;
import java.awt.Frame;
import java.awt.AWTError;
import java.awt.Image;
import java.awt.image.FilteredImageSource;
import Acme.JPM.Encoders.GifEncoder;
import com.eteks.filter.Web216ColorsFilter;
import com.eteks.awt.servlet.PJAServlet;
* This servlet manages in a simple way a dynamic survey and returns the pie of the survey.
* It can be called in either ways :
* <UL><LI><code>.../servlet/com.eteks.servlet.TeksSurveyPie?survey=mySurvey&answer=myAnswer</code>
* adds the answer <code>myAnswer</code> to the survey <code>mySurvey</code>,
* and then returns the pie of the current state of <code>mySurvey</code>.
* <LI><code>.../servlet/com.eteks.servlet.TeksSurveyPie?survey=mySurvey</code>
* simply returns the pie of the current state of <code>mySurvey</code>.</UL>
* <P>To be platform independant, the servlet uses <code>com.eteks.awt.servlet.PJAServlet</code> as super class,
* to have at disposal an image into which graphics operation can be performed.<BR>
* <code>com.eteks.awt.PJAServlet</code> class and depending classes of <code>com.eteks.awt</code> packages
* must be in the servlet engine classpath, and at least one .pjaf font file (Pure Java AWT Font) must exist
* in the user directory or in the directory set in the <code>java.awt.fonts</code> system property,
* if JVM version <= 1.1.<BR>
public class TeksSurveyPie extends PJAServlet
Properties surveysParam = new Properties ();
String fontsDir = ""; // Default value for "java.awt.fonts" .pjaf fonts directory initParameter
String surveysFile = fontsDir + File.separator + "survey.txt"; // Default value for survey file initParameter
// Colors used to fill the pie
final Color colors [] = {Color.blue,
Color.green,
Color.red,
Color.cyan,
Color.magenta,
Color.gray,
Color.yellow,
Color.pink,
Color.orange,
Color.white};
final Color penColor = Color.black;
public void initPJA (ServletConfig config) throws ServletException
// Store the ServletConfig object and log the initialization
super.initPJA (config);
// Retrieves surveys file path
String param = getInitParameter ("surveysFile");
if (param != null)
surveysFile = param;
param = getInitParameter ("fontsDir");
if (param != null)
fontsDir = param;
FileInputStream in = null;
try
in = new FileInputStream (surveysFile);
surveysParam.load (in);
catch (IOException e)
{ } // Empty properties
finally
try
if (in != null)
in.close ();
catch (IOException ex)
public void destroyPJA ()
try
surveysParam.save (new FileOutputStream (surveysFile), "Survey file");
catch (IOException e)
{ } // Properties can't be saved
public String getFontsPath ()
return super.getFontsPath () + File.pathSeparator
+ fontsDir;
public void doPostPJA (HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
doGetPJA (request, response);
public void doGetPJA (HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
String survey = request.getParameter ("survey"); // Survey name
String answer = request.getParameter ("answer"); // Proposed answer
String paramWidth = request.getParameter ("width");
String paramHeight = request.getParameter ("height");
int width = paramWidth == null ? 200 : Integer.parseInt (paramWidth);
int height = paramHeight == null ? 100 : Integer.parseInt (paramHeight);
// v1.1 : Changed code to enable image creation
// even if PJAToolkit couldn't be loaded by Toolkit.getDefaultToolkit ()
Image image = createImage (width, height);
if (survey == null)
survey = "";
if (answer != null)
String key = survey + "_" + answer;
String value = surveysParam.getProperty (key);
if (value != null)
// If the answer already exists, increase its value
surveysParam.put (key, String.valueOf (Integer.parseInt (value) + 1));
else
String surveyAnswers = surveysParam.getProperty (survey);
// Add this answer to the other ones
if (surveyAnswers == null)
surveysParam.put (survey, answer);
else
surveysParam.put (survey, surveyAnswers + "," + answer);
surveysParam.put (key, "1");
Hashtable answers = new Hashtable ();
Vector sortedAnswers = new Vector ();
synchronized (surveysParam)
String surveyAnswers = surveysParam.getProperty (survey);
if (surveyAnswers != null)
for (StringTokenizer tokens = new StringTokenizer (surveyAnswers, ",");
tokens.hasMoreTokens (); )
String token = tokens.nextToken ();
int answerCount = Integer.parseInt (surveysParam.getProperty (survey + "_" + token));
answers.put (token, new Integer (answerCount));
// Seek the good place to insert this element
int i;
for (i = 0; i < sortedAnswers.size (); i++)
if (answerCount > ((Integer)answers.get (sortedAnswers.elementAt (i))).intValue ())
break;
sortedAnswers.insertElementAt (token, i);
// Compute the pies of the survey
drawSurveyPies (image, answers, sortedAnswers, width, height);
// Send generated image
sendGIFImage (image, response);
* Generates a GIF image on the response stream from image.
public void sendGIFImage (Image image, HttpServletResponse response) throws ServletException, IOException
// Set content type and other response header fields first
response.setContentType("image/gif");
// Then write the data of the response
OutputStream out = response.getOutputStream ();
try
new GifEncoder (image, out).encode ();
catch (IOException e)
// GifEncoder may throw an IOException because "too many colors for a GIF" (> 256)
// were found in the image
// Reduce the number of colors in that case with Web216ColorsFilter basic filter
new GifEncoder (new FilteredImageSource (image.getSource (),
new Web216ColorsFilter ()),
out).encode ();
out.flush ();
private void drawSurveyPies (Image image,
Hashtable answers,
Vector sortedAnswers,
int width,
int height)
Graphics gc = image.getGraphics ();
// Draw a shadow
gc.setColor (penColor);
gc.fillOval (1, 1, height - 3, height - 3);
gc.fillOval (2, 2, height - 3, height - 3);
// Compute the sum of all values
int sum = 0;
for (Enumeration e = answers.elements ();
e.hasMoreElements (); )
sum += ((Integer)e.nextElement ()).intValue ();
for (int accum = 0, i = 0, deltaY = 0; i < sortedAnswers.size (); i++, deltaY += 15)
int answerValue = ((Integer)answers.get (sortedAnswers.elementAt (i))).intValue ();
int startAngle = accum * 360 / sum;
int angle = answerValue * 360 / sum;
// Fill the anwser pie
gc.setColor (colors [i % colors.length]);
gc.fillArc (0, 0, height - 3, height - 3, startAngle, angle);
// Draw a separating line
gc.setColor (penColor);
gc.drawLine ((height - 3) / 2, (height - 3) / 2,
(int)((height - 3) / 2. * (1 + Math.cos (startAngle / 180. * Math.PI)) + 0.5),
(int)((height - 3) / 2. * (1 - Math.sin (startAngle / 180. * Math.PI)) + 0.5));
accum += answerValue;
if (deltaY + 15 < height)
// Add a comment
gc.setColor (colors [i % colors.length]);
gc.fillRect (height + 6, deltaY + 1, 13, 10);
gc.setColor (penColor);
gc.drawRect (height + 5, deltaY, 14, 11);
// Draw is done with default font
gc.drawString (String.valueOf (100 * answerValue / sum) + "% " + (String)sortedAnswers.elementAt (i),
height + 22, deltaY + 9);
gc.drawLine ((height - 3) / 2, (height - 3) / 2, height - 3, (height - 3) / 2);
// Draw a surrounding oval
gc.drawOval (0, 0, height - 3, height - 3);
Thx
prabhu -
Obtaining client certificate in servlet using apache + tomcat
Hi,
I'm porting a webapplication from Javawebserver to Apache/1.3.6 (Win32) mod_jk mod_ssl/2.2.6 OpenSSL/0.9.2b
The application needs to get the client certificate hash code.
Using Javawebserver I used
request.getAttribute ("javax.net.ssl.cipher_suite");
request.getAttribute("javax.net.ssl.peer_certificates");
etc
How do I set up the apache webserver so that I can read the client certificate and what is the attribute called?
I've tried this in the httpd.conf:
SSLOptions +ExportCertData
And the attribute:
"SSL_CLIENT_CERT"
Like it says in the Tomcat documentation.
I'm not sure if I need to set up Tomcat as well..
Any help would be greatly appriciated!
Sincerely,
AM HjemaasYup use ajp13 not ajp12 or mod_webapp
refer to http://www.galatea.com/flashguides/apache-tomcat-24-win32.xml on setting up..
THIS IS IMPORTANT!!!
use Apache mod_jk.dll diretive:
JkEnvVar Apache_Env_Var FORWARD_ALIAS
this will send a apache environment variable (http://myapache/cgi-bin/printenv.pl to see whats available) to Tomcat
JkEnvVar SSL_CLIENT_CERT SSL_CLIENT_CERT
Then in Tomcat servlet use request.getAttribute("SSL_CLIENT_CERT") to get the cert in PEM format
Hope this helps
Jay -
Cannot run a servlet using Tomcat. Urgent
I have a webapplication which uses some jsp's and servlets. The jsp pages work fine when I use
http://hostname:8080/MyWebapp/Filename.jsp
However, when I developed a java servlet and put the class file in WEB-INF/classes directory of my web application and tried to access it.
I got a resource not found error.
The strange thing is that when I put the file in the web-inf/classes folder of examples webapplication (which comes with Tomcat) I am able to run the servlet using
http://hostname:8080/examples/servlet/Class file
I am not sure what is wrong.
Can someone help me.
Thanks in advance
Vamsi.It's predictable. The Servlet and JSP specifications mandate that you cannot directly access resources under WEB-INF directory. You have to set up servlet mapping configuration in your web.xml to specify how to access the resources, both Servlet and JSP, there.
When you copied your files in a demo webapp of Tomcat, the web.xml of the demo app already set up the mapping like following for you. So you could use http://hostname:8080/examples/servlet/Class to visit the servlet.
<servlet-mapping>
<servlet-name>invoker</servlet-name>
<url-pattern>/servlet/*</url-pattern>
</servlet-mapping>
The default setting since Tomcat 4.1 turned off servlet invoker in web.xml under conf directory. You can uncomment the above lines in this file to turn it on. Then you are able to visit your servlet without <servlet-mapping> configured using the following syntax,
http://hostname:8080/<your_app_name>/servlet/<your_servlet_name> -
Testing model using UI does not open in the UI
I created a UI for a model and when trying to test it (using Test Model > Start a new configuration > Model UI (select the UI) > Finish), it does not bring up the UI, instead it shows the Configuration Summary page. I have checked the UI and it has the page flow defined properly. What is the reason for this and what is the solution. Thanks in advance.
Thanks Pankaj, the page flow mentioned in the UI was wrong. I modified it to the correct one. But, now when I test, an error page is displayed. This model has only one UI page.
Error Page
You have encountered an unexpected error. Please contact the System Administrator for assistance.
I have this issue with another model also for which there are 4 UI pages, while testing the first 3 display properly while the above error occurs on the last page.
Based on the above, it seems the error is thrown on the last page of the UI. Is there anything else I can check to resolve this issue? Thanks.
Maybe you are looking for
-
i moved all of my music to my new computer and now the songs stop before the end of them or it skips to the next one on the ipod how can i fix it easily
-
Using Keynote and iPhoto slideshow together
Computer: 12" Powerbook G4, 1.5ghz Display: 23" Apple Cinema Display (1920x1200) Software: OSX 10.4.9, Keynote 2, iPhoto 6 Hi everyone! Above are the specs for the project I'm working on and here's the problem I'm having: I am trying to create a make
-
Hi, I need to send the cost centers from one system to another. I want to use BD16 (IDOC) for the same but both these systems have different controlling area. BD16 works only when both the sender and receiver have same controlling area. Can you pleas
-
UIwebview load local html file problem
Hi, load local html file into UIwebview the TD cell data can't display, as attached the "2817 MODEL" column data lost on screen: The local html file souce as: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/
-
Getting black screen between chunks of clip
Hi all, We are developing an application which plays the series of clips one after the other. We are releasing and re-starting player object in playerUpdate block. We are getting black screen in between the chunk of clips while switching from one cli