JSP Help needed
i'm now starting to study JSPs and just bought a
book by Wrox(Java Server Programming) and i have a problem with
some codes..i always got exception and i don't knwo why,..maybe you
could help me out..here is my simple code adn the exeption and also
my classpath settings:
ClassPath:
.;%classpath%;
%JAVA_HOME%\lib\tools.jar;
.;%J2EE_HOME%\lib\j2ee.jar;
.;%TOMCAT_HOME%\lib\servlet.jar;
.;%JAVA_HOME%\jre\lib\rt.jar;
.;%JAVA_HOME%\lib;
.;%JAVA_HOME%\jre\lib\ext\servlet.jar
Path:
%SYSTEMROOT%;
%SYSTEMROOT%\COMMAND;
.;%JAVA_HOME%\bin;
c:\Tomcat\bin;
%SYSTEMROOT%\system32;
%SYSTEMROOT%\system32\WBEM;
c:\windows\command;
.;%J2EE_HOME%\bin
Here is my Jsp code:
<%@page import="java.util.Date"%>
<html>
<body>
The current time is <%= new Date().toString() %>
</body>
</html>
Here is the Exception:
Error: 500
Location: /JSPExamples/simple.jsp
Internal Servlet Error:
javax.servlet.ServletException
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:399)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:840)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
at org.apache.tomcat.core.Handler.service(Handler.java:286)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:210)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
at java.lang.Thread.run(Thread.java:484)
Root cause:
java.lang.NoSuchMethodError
at org.apache.jasper.runtime.JspWriterImpl.flush(JspWriterImpl.java:209)
at _0002fsimple_0002ejspsimple_jsp_0._jspService(_0002fsimple_0002ejspsimple_jsp_0.java:75)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:840)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:177)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:318)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:391)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:840)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
at org.apache.tomcat.core.Handler.service(Handler.java:286)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:210)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
at java.lang.Thread.run(Thread.java:484)
it worked OK on my machine. Can you browse Tomcat's default content OK? For example, if you point your browser at:
http://localhost:8080
Do you see the tomcat "homepage"? If so, try clicking on some of the JSP examples there - do they work?
Another thing to try is this: look in the tomcat directory, and you'll find a subdirectory called "work". This is the "cache" directory, where tomcat puts the servlet code it has generated from your JSP.
There will probably be a few subdirectories within this "work" directory, all called something like "localhost_8080%2FMYAppname". In one of these directories you'll find a file called "_0002fsimple_0002ejspsimple_jsp_0.java"
If you open this in an editor you can look at line 75 to see exactly what the thing is barfing on.
Similar Messages
-
OpenDocument.jsp help needed
I am trying to configure a URL link to a crystal reports.
This has been done
1. Crystal reports created, connected to SAP.
2. Report saved to CMS.
3. Run, Viewed last instance in Infoview.
I would like to create a URL to view this report, so I have this.
http://hostname:port/OpenDocument/opendoc/openDocument.jsp?docid=7941&sInstance=Last
I get directed to a logon page. the logon page has url properties of this:
http://hostname:port/PartnerPlatformService/service/app/logon.do?appKind=InfoView&service=%2FOpenDocument%2FappService.do&backContext=%2FOpenDocument&backUrl=%2Fopendoc%2FopenDocument.jsp%3Fdocid%3D7941%26appKind%3DInfoView%26isApplication%3Dtrue%26sInstance%3DLast&backUrlParents=1&appName=OpenDocument&prodName=BusinessObjects+Enterprise&cmsVisible=false&cms=hostname%3A6400&authenticationVisible=false&authType=secEnterprise&sso=true&sm=false&smAuth=secLDAP&persistCookies=true&sessionCookie=true&useLogonToken=true
I logon with crystal admin user
And I get the page http://hostname:port/PlatformServices/service/app/error.do
An error has occurred: An error occured while trying to view the document
Any direction as to what has gone wrong is greatly appreciated! Thank you!Hi,
do you use docid or iDocID in your URL. Please note that the parameter names are case-sensitive.
I would recommend to take a look at the documentation in order to identify the correct syntax for your URL
[http://help.sap.com/businessobject/product_guides/boexir31/en/xi3-1_url_reporting_opendocument_en.pdf]
Regards,
Stratos -
hi all
i am using JSTL for my jsp in tomcat 5.5. the following code always gives me exception:
<fmt:message key="viewbills.title" bundle="${lang}"/>javax.servlet.jsp.JspException: An error occurred while evaluating custom action attribute "bundle" with value "${lang}": Attempt to convert String "en" to type "javax.servlet.jsp.jstl.fmt.LocalizationContext", but there is no PropertyEditor for that type (null)
does anyone know what the cause is and way of fixing it> thanks a lot.You're never submitting the data on your form to the selectedexercises.jsp. All you're doing is telling the first.jsp to open this page in a new window -- you're never passing parameters to that new window.
One way to do it would be to change your form tag to be:
<form name="f1" action="/ap1/selectedexercises.jsp">
This will go to selectedexercises.jsp with the form data as parameters to the page.
I'm assuming that's what you're trying to do -- it's tough to tell from these code samples.
Hope that helps,
Mike -
JSP tags with java beans !! Design Help needed ..
Hi,
I have three tables State,District,College.
My requirement is to get the fields from three tables one time from the DB and populate them with the JSP(so that the DB connections will not be much).
For that :::
I have designed to have three Beans StateBean,DistrictBean and CollegeBean.
Every row in State table will be a StateBean and will be added to an ArrayList called StateBeanList
similarly I got two other lists DistrictBeanList and CollegeBeanList.
And I am using application.setAttribute() to send all the information to the JSP by using RequestDespatcher..
When I run the servlet on tomcat it is getting OutOfMemory Exception in java Heap..Can I increase the heap size on tomcat ?
Apart from increasing the heap size I want to know good design...
My actual requirement is::: in the forwared JSP I need to populate state text field and after selecting state field I need to get the district fileds populated in other text filed, by the value of district field I need to populate college field... we can see it many websites...
Please suggest me the good design..
Thanks in Advance,
Vidhya...vidhya517 wrote:
I have three tables State,District,College.
My requirement is to get the fields from three tables one time from the DB and populate them with the JSP(so that the DB connections will not be much).
For that :::
I have designed to have three Beans StateBean,DistrictBean and CollegeBean.
Every row in State table will be a StateBean and will be added to an ArrayList called StateBeanList
similarly I got two other lists DistrictBeanList and CollegeBeanList.I would rather let StateBean have a Set<DistrictBean> property and let DistrictBean have a Set<CollegeBean> property. List instead of Set is also okay.
And I am using application.setAttribute() to send all the information to the JSP by using RequestDespatcher..
When I run the servlet on tomcat it is getting OutOfMemory Exception in java Heap..Can I increase the heap size on tomcat ?
Apart from increasing the heap size I want to know good design...How many states, districts and colleges do you have in total? What is your initial heap size? You can just alter it as startup parameters/arguments.
My actual requirement is::: in the forwared JSP I need to populate state text field and after selecting state field I need to get the district fileds populated in other text filed, by the value of district field I need to populate college field... we can see it many websites...
Please suggest me the good design.. -
Help needed to run JSTL 1.1 in Tomcat 6.0.16
Hi All,Help needed to run JSTL 1.1 in Tomcat 6.0.16. I am trying to run the example given in http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.html The example tries to connect to MySQL database from JSP using JSTL and JNDI Datasource.I am running the example using Eclipse 3.4.2 using Sysdeo plugin to start and stop Tomcat server from Eclipse IDE.
My web.xml file has <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
</web-app>
and test.jsp has proper taglib directives
<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
I have placed the jstl.jar and standard.jarof the jakarta-taglibs-standard-1.1.2.zip under E:\Deepa\workspace\DBTest\WebContent\WEB-INF\lib directory also placedcontext.xml file under E:\Deepa\workspace\DBTest\WebContent\META-INF and the content of context.xml is as below
<Context path="/DBTest" docBase="DBTest"
debug="5" reloadable="true" crossContext="true">
<Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="deepa" password="mysql" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/javatest?autoReconnect=true"/>
</Context>
Now while running the example, Eclipse creates one DBTest.xml file under C:\Program Files\Apache Software Foundation\Tomcat 6.0\conf\Catalina\localhost
which has the following line:
<Context path="/DBTest" reloadable="true" docBase="E:\Deepa\workspace\DBTest" workDir="E:\Deepa\workspace\DBTest\work" />
I am getting the following error when running http://localhost/DBTest/WebContent/test.jsp
in Browser:
<HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/sql cannot be resolved in either web.xml or the jar files deployed with this application
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:51)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:116)
org.apache.jasper.compiler.TagLibraryInfoImpl.generateTLDLocation(TagLibraryInfoImpl.java:315)
org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:148)
org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:431)
org.apache.jasper.compiler.Parser.parseDirective(Parser.java:494)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1444)
org.apache.jasper.compiler.Parser.parse(Parser.java:138)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:216)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:103)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:154)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:315)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:282)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
In the Tomcat Server console, I am getting the following error:
INFO: Server startup in 7295 ms
May 20, 2009 6:36:48 AM org.apache.jasper.compiler.TldLocationsCache processWebDotXml
WARNING: Internal Error: File /WEB-INF/web.xml not found
May 20, 2009 6:36:48 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/sql cannot be resolved in either web.xml or the jar files deployed with this application
what is the problem with my code?
When running the same example, by creating a local server in Eclipse(creating new Server connection pointing to same Tomcat 6.0 installation) it runs fine without any error.Hi evnafets,
Wow, very helpful information, great insight into working of Eclipse. Thanks a lot.
I have one more question. I have a context.xml file under {color:#0000ff}E:\Deepa\workspace\DBTest\WebContent\META-INF{color} folder and that has the Resource element to connect to MySQL database:
{code{color:#000000}}{color}<Context path="/DBTest" docBase="DBTest" debug="5" reloadable="true" crossContext="true">
<Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource" maxActive="100" maxIdle="30" maxWait="10000" username="deepa" password="mysql" driverClassName="com.mysql.jdbc.Driver"
{color:#0000ff}url="jdbc:mysql://localhost:3306/javatest?autoReconnect=true"/>{color}
{color:#0000ff}</Context>{color}As usual when running application in local Tomcat server of Eclipse, this data source works fine. But when I run the application on Tomcat, by starting Sysdeo plugin from Eclipse, the DBTest.xml file created in C:\Tomcat 6.0\conf\Catalina\localhost has the context entry as<Context path="/DBTest" reloadable="true" docBase="E:\Deepa\workspace\DBTest\WebContent" workDir="E:\Deepa\workspace\DBTest\work">
</Context>The<Resource> element I have specified in the context.xml of \WebContent\META-INF folder is not taken into account by Tomcat and it gives the following error:May 21, 2009 5:20:04 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet jsp threw exception
javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "org.apache.tomcat.dbcp.dbcp.SQLNestedException_: Cannot create JDBC driver of class '' for connect URL 'null'"
_at org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.getConnection(_QueryTagSupport.java:276_)
at org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.doStartTag(_QueryTagSupport.java:159_)
at org.apache.jsp.test_jsp._jspx_meth_sql_005fquery_005f0(_test_jsp.java:113_)
at org.apache.jsp.test_jsp._jspService(_test_jsp.java:66_)
at org.apache.jasper.runtime.HttpJspBase.service(_HttpJspBase.java:70_)
at javax.servlet.http.HttpServlet.service(_HttpServlet.java:717_)
at org.apache.jasper.servlet.JspServletWrapper.service(_JspServletWrapper.java:374_)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(_JspServlet.java:342_)
at org.apache.jasper.servlet.JspServlet.service(_JspServlet.java:267_)
at javax.servlet.http.HttpServlet.service(_HttpServlet.java:717_)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(_ApplicationFilterChain.java:290_)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(_ApplicationFilterChain.java:206_)
at org.apache.catalina.core.StandardWrapperValve.invoke(_StandardWrapperValve.java:233_)
at org.apache.catalina.core.StandardContextValve.invoke(_StandardContextValve.java:191_)
at org.apache.catalina.core.StandardHostValve.invoke(_StandardHostValve.java:128_)
at org.apache.catalina.valves.ErrorReportValve.invoke(_ErrorReportValve.java:102_)
at org.apache.catalina.core.StandardEngineValve.invoke(_StandardEngineValve.java:109_)
at org.apache.catalina.connector.CoyoteAdapter.service(_CoyoteAdapter.java:286_)
at org.apache.coyote.http11.Http11Processor.process(_Http11Processor.java:845_)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(_Http11Protocol.java:583_)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(_JIoEndpoint.java:447_)
at java.lang.Thread.run(_Thread.java:619_)
{code}
So to overcome this error I had to place the <Resource> element in DBTest.xml under C:\Tomcat 6.0\conf\Catalina\localhost {color:#000000}and then it works fine. {color}{color:#ff0000}*Why is the context.xml file in META-INF not considered by Tomcat server using Sysdeo Plugin?*
*Thanks,*
*Deepa*{color}
{color}
Edited by: Deepa76 on May 26, 2009 9:32 PM -
Help needed:Printing HTML file using javax.print
Hi
I am using the following code which i got form the forum for rpinting an HTML file.
The folllowing code is working fine, but the problem is the content of HTML file is not getting printed. I am geeting a blank page with no content. What is the change that is required in the code? ALso is there any simpler way to implement this. Help needed ASAP.
public boolean printHTMLFile(String filename) {
try {
JEditorPane editorPane = new JEditorPane();
editorPane.setEditorKit(new HTMLEditorKit());
//editorPane.setContentType("text/html");
editorPane.setSize(500,500);
String text = getFileContents(filename);
if (text != null) {
editorPane.setText(text);
} else {
return false;
printEditorPane(editorPane);
return true;
} catch (Exception tce) {
tce.printStackTrace();
return false;
public String getFileContents(String filename) {
try {
File file = new File(filename);
BufferedReader br = new BufferedReader(new FileReader(file));
String line;
StringBuffer sb = new StringBuffer();
while ((line = br.readLine()) != null) {
sb.append(line);
br.close();
return sb.toString();
} catch (Exception tce) {
tce.printStackTrace();
return null;
public void printEditorPane(JEditorPane editorPane) {
try {
HTMLPrinter htmlPrinter = new HTMLPrinter();
htmlPrinter.printJEditorPane(editorPane, htmlPrinter.showPrintDialog());
} catch (Exception tce) {
tce.printStackTrace();
* Sets up to easily print HTML documents. It is not necessary to call any of the setter
* methods as they all have default values, they are provided should you wish to change
* any of the default values.
public class HTMLPrinter {
public int DEFAULT_DPI = 72;
public float DEFAULT_PAGE_WIDTH_INCH = 8.5f;
public float DEFAULT_PAGE_HEIGHT_INCH = 11f;
int x = 100;
int y = 80;
GraphicsConfiguration gc;
PrintService[] services;
PrintService defaultService;
DocFlavor flavor;
PrintRequestAttributeSet attributes;
Vector pjlListeners = new Vector();
Vector pjalListeners = new Vector();
Vector psalListeners = new Vector();
public HTMLPrinter() {
gc = null;
attributes = new HashPrintRequestAttributeSet();
flavor = null;
defaultService = PrintServiceLookup.lookupDefaultPrintService();
services = PrintServiceLookup.lookupPrintServices(flavor, attributes);
// do something with the supported docflavors
DocFlavor[] df = defaultService.getSupportedDocFlavors();
for (int i = 0; i < df.length; i++)
System.out.println(df.getMimeType() + " " + df[i].getRepresentationClassName());
// if there is a default service, but no other services
if (defaultService != null && (services == null || services.length == 0)) {
services = new PrintService[1];
services[0] = defaultService;
* Set the GraphicsConfiguration to display the print dialog on.
* @param gc a GraphicsConfiguration object
public void setGraphicsConfiguration(GraphicsConfiguration gc) {
this.gc = gc;
public void setServices(PrintService[] services) {
this.services = services;
public void setDefaultService(PrintService service) {
this.defaultService = service;
public void setDocFlavor(DocFlavor flavor) {
this.flavor = flavor;
public void setPrintRequestAttributes(PrintRequestAttributeSet attributes) {
this.attributes = attributes;
public void setPrintDialogLocation(int x, int y) {
this.x = x;
this.y = y;
public void addPrintJobListener(PrintJobListener pjl) {
pjlListeners.addElement(pjl);
public void removePrintJobListener(PrintJobListener pjl) {
pjlListeners.removeElement(pjl);
public void addPrintServiceAttributeListener(PrintServiceAttributeListener psal) {
psalListeners.addElement(psal);
public void removePrintServiceAttributeListener(PrintServiceAttributeListener psal) {
psalListeners.removeElement(psal);
public boolean printJEditorPane(JEditorPane jep, PrintService ps) {
if (ps == null || jep == null) {
System.out.println("printJEditorPane: jep or ps is NULL, aborting...");
return false;
// get the root view of the preview pane
View rv = jep.getUI().getRootView(jep);
// get the size of the view (hopefully the total size of the page to be printed
int x = (int) rv.getPreferredSpan(View.X_AXIS);
int y = (int) rv.getPreferredSpan(View.Y_AXIS);
// find out if the print has been set to colour mode
DocPrintJob dpj = ps.createPrintJob();
PrintJobAttributeSet pjas = dpj.getAttributes();
// get the DPI and printable area of the page. use default values if not available
// use this to get the maximum number of pixels on the vertical axis
PrinterResolution pr = (PrinterResolution) pjas.get(PrinterResolution.class);
int dpi;
float pageX, pageY;
if (pr != null)
dpi = pr.getFeedResolution(PrinterResolution.DPI);
else
dpi = DEFAULT_DPI;
MediaPrintableArea mpa = (MediaPrintableArea) pjas.get(MediaPrintableArea.class);
if (mpa != null) {
pageX = mpa.getX(MediaPrintableArea.INCH);
pageY = mpa.getX(MediaPrintableArea.INCH);
} else {
pageX = DEFAULT_PAGE_WIDTH_INCH;
pageY = DEFAULT_PAGE_HEIGHT_INCH;
int pixelsPerPageY = (int) (dpi * pageY);
int pixelsPerPageX = (int) (dpi * pageX);
int minY = Math.max(pixelsPerPageY, y);
// make colour true if the user has selected colour, and the PrintService can support colour
boolean colour = pjas.containsValue(Chromaticity.COLOR);
colour = colour & (ps.getAttribute(ColorSupported.class) == ColorSupported.SUPPORTED);
// create a BufferedImage to draw on
int imgMode;
if (colour)
imgMode = BufferedImage.TYPE_3BYTE_BGR;
else
imgMode = BufferedImage.TYPE_BYTE_GRAY;
BufferedImage img = new BufferedImage(pixelsPerPageX, minY, imgMode);
Graphics myGraphics = img.getGraphics();
myGraphics.setClip(0, 0, pixelsPerPageX, minY);
myGraphics.setColor(Color.WHITE);
myGraphics.fillRect(0, 0, pixelsPerPageX, minY);
java.awt.Rectangle rectangle=new java.awt.Rectangle(0,0,pixelsPerPageX, minY);
// call rootView.paint( myGraphics, rect ) to paint the whole image on myGraphics
rv.paint(myGraphics, rectangle);
try {
// write the image as a JPEG to the ByteArray so it can be printed
Iterator writers = ImageIO.getImageWritersByFormatName("jpeg");
ImageWriter writer = (ImageWriter) writers.next();
// mod: Added the iwparam to create the highest quality image possible
ImageWriteParam iwparam = writer.getDefaultWriteParam();
iwparam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT) ;
iwparam.setCompressionQuality(1.0f); // highest quality
ByteArrayOutputStream out = new ByteArrayOutputStream();
ImageOutputStream ios = ImageIO.createImageOutputStream(out);
writer.setOutput(ios);
// get the number of pages we need to print this image
int imageHeight = img.getHeight();
int numberOfPages = (int) Math.ceil(minY / (double) pixelsPerPageY);
// print each page
for (int i = 0; i < numberOfPages; i++) {
int startY = i * pixelsPerPageY;
// get a subimage which is exactly the size of one page
BufferedImage subImg = img.getSubimage(0, startY, pixelsPerPageX, Math.min(y - startY, pixelsPerPageY));
// mod: different .write() method to use the iwparam parameter with highest quality compression
writer.write(null, new IIOImage(subImg, null, null), iwparam);
SimpleDoc sd = new SimpleDoc(out.toByteArray(), DocFlavor.BYTE_ARRAY.JPEG, null);
printDocument(sd, ps);
// reset the ByteArray so we can start the next page
out.reset();
} catch (PrintException e) {
System.out.println("Error printing document.");
e.printStackTrace();
return false;
} catch (IOException e) {
System.out.println("Error creating ImageOutputStream or writing to it.");
e.printStackTrace();
return false;
// uncomment this code and comment out the 'try-catch' block above
// to print to a JFrame instead of to the printer
/* JFrame jf = new JFrame();
PaintableJPanel jp = new PaintableJPanel();
jp.setImage( img );
JScrollPane jsp = new JScrollPane( jp );
jf.getContentPane().add( jsp );
Insets i = jf.getInsets();
jf.setBounds( 0, 0, newX, y );
jf.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE );
jf.setVisible( true );*/
return true;
* Print the document to the specified PrintService.
* This method cannot tell if the printing was successful. You must register
* a PrintJobListener
* @return false if no PrintService is selected in the dialog, true otherwise
public boolean printDocument(Doc doc, PrintService ps) throws PrintException {
if (ps == null)
return false;
addAllPrintServiceAttributeListeners(ps);
DocPrintJob dpj = ps.createPrintJob();
addAllPrintJobListeners(dpj);
dpj.print(doc, attributes);
return true;
public PrintService showPrintDialog() {
return ServiceUI.printDialog(gc, x, y, services, defaultService, flavor, attributes);
private void addAllPrintServiceAttributeListeners(PrintService ps) {
// add all listeners that are currently added to this object
for (int i = 0; i < psalListeners.size(); i++) {
PrintServiceAttributeListener p = (PrintServiceAttributeListener) psalListeners.get(i);
ps.addPrintServiceAttributeListener(p);
private void addAllPrintJobListeners(DocPrintJob dpj) {
// add all listeners that are currently added to this object
for (int i = 0; i < pjlListeners.size(); i++) {
PrintJobListener p = (PrintJobListener) pjlListeners.get(i);
dpj.addPrintJobListener(p);
// uncomment this also to print to a JFrame instead of a printer
/* protected class PaintableJPanel extends JPanel {
Image img;
protected PaintableJPanel() {
super();
public void setImage( Image i ) {
img = i;
public void paint( Graphics g ) {
g.drawImage( img, 0, 0, this );
Thanks
RamRam,
I have had printing problems too a year and a half ago. I used all printing apis of java and I still find that it is something java lacks. Now basically you can try autosense. To check whether your printer is capable of printing the docflavor use this PrintServiceLookup.lookupPrintServices(flavor, aset); . If it lists the printer then he can print the document otherwise he can't. I guess that is why you get the error.
Regards,
Kevin -
Troubleshooting help needed: My iMac keeps crashing and restarting with a notice: "Spinlock application timed out" What can I do?
Launch the Console application in any of the following ways:
☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
☞ Open LaunchPad. Click Utilities, then Console in the page that opens.
Select the most recent panic log under System Diagnostic Reports. Post the contents — the text, please, not a screenshot. In the interest of privacy, I suggest you edit out the “Anonymous UUID,” a long string of letters, numbers, and dashes in the header and body of the report, if it’s present (it may not be.) Please don't post shutdownStall, spin, or hang reports. -
help needed for writing query
i have the following tables(with data) as mentioned below
FK*-foregin key (SUBJECTS)
FK**-foregin key (COMBINATION)
1)SUBJECTS(table name)
SUB_ID(NUMBER) SUB_CODE(VARCHAR2) SUB_NAME (VARCHAR2)
2 02 Computer Science
3 03 Physics
4 04 Chemistry
5 05 Mathematics
7 07 Commerce
8 08 Computer Applications
9 09 Biology
2)COMBINATION
COMB_ID(NUMBER) COMB_NAME(VARCHAR2) SUB_ID1(NUMBER(FK*)) SUB_ID2(NUMBER(FK*)) SUB_ID3(NUMBER(FK*)) SUBJ_ID4(NUMBER(FK*))
383 S1 9 4 2 3
384 S2 4 2 5 3
---------I actually designed the ABOVE table also like this
3) a)COMBINATION
COMB_ID(NUMBER) COMB_NAME(VARCHAR2)
383 S1
384 S2
b)COMBINATION_DET
COMBDET_ID(NUMBER) COMB_ID(FK**) SUB_ID(FK*)
1 383 9
2 383 4
3 383 2
4 383 3
5 384 4
6 384 2
7 384 5
8 384 3
Business rule: a combination consists of a maximum of 4 subjects (must contain)
and the user is less relevant to a COMB_NAME(name of combinations) but user need
the subjects contained in combinations
i need the following output
COMB_ID COMB_NAME SUBJECT1 SUBJECT2 SUBJECT3 SUBJECT4
383 S1 Biology Chemistry Computer Science Physics
384 S2 Chemistry Computer Science Mathematics Physics
or even this is enough(what i actually needed)
COMB_ID subjects
383 Biology,Chemistry,Computer Science,Physics
384 Chemistry,Computer Science,Mathematics,Physics
you can use any of the COMBINATION table(either (2) or (3))
and i want to know
1)which design is good in this case
(i think SUB_ID1,SUB_ID2,SUB_ID3,SUB_ID4 is not a
good method to link with same table but if 4 subjects only(and must) comes
detail table is not neccessary )
now i am achieving the result by program-coding in C# after getting the rows from oracle
i am using oracle 9i (also ODP.NET)
i want to know how can i get the result in the stored procedure itsef.
2)how it could be designed in any other way.
any help/suggestion is welcome
thanks for your time --PradeeshWell I forgot the table-alias, here now with:
SELECT C.COMB_ID
, C.COMB_NAME
, (SELECT SUB_NAME
FROM SUBJECTS
WHERE SUB_ID = C.SUB_ID1) AS SUBJECT_NAME1
, (SELECT SUB_NAME
FROM SUBJECTS
WHERE SUB_ID = C.SUB_ID2) AS SUBJECT_NAME2
, (SELECT SUB_NAME
FROM SUBJECTS
WHERE SUB_ID = C.SUB_ID3) AS SUBJECT_NAME3
, (SELECT SUB_NAME
FROM SUBJECTS
WHERE SUB_ID = C.SUB_ID4) AS SUBJECT_NAME4
FROM COMBINATION C;
As you need exactly 4 subjects, the columns-solution is just fine I would say. -
Hi all help needed I have a canon 40D. I am thinking of buying a canon 6D.
But not sure that my lenses will work.
I have a 170mm/ 500mm APO Sigma.
A 10/20 ex Sigma HSM IF.
And a 180 APO Sigma Macro or do I have to scrap them and buy others.
ALL Help will be greatly received. Yours BRODIEIn short, I love it. I was going to buy the 5DMark III. After playing with it for a while at my local Fry's store where they put 5DMII, 5DMIII and 6D next to each other, using the same 24-105L lens, I decided to get the 6D and pocket the different for lens later.
I'm upgrading from the 30D. So I think you'll love it. It's a great camera. I have used 5DMII extensively before (borrowing from a close friend).
Funny thing is at first I don't really care about the GPS and Wifi much. I thought they're just marketing-gimmick. But once you have it, it is actually really fun and helpful. For example, I can place the 6D on a long "monopod", then use the app on the phone to control the camera to get some unique perspective on some scenes. It's fun and great. GPS is also nice for travel guy like me.
Weekend Travelers Blog | Eastern Sierra Fall Color Guide -
Help needed! Raid degraded again!
Hi!
Help needed! I hava made bootable RAID with two S-ATAII 250Gb HDD and its not working! Every now and then at bootup I get a message RAID -> DEGRADED... Must be seventh time! Rebuild takes its own time!
What am I doing wrong!
T: Ekku
K8N Neo4 Ultra
AMD 64 4200+
2 Gb RAM
2 x 250 Gb HDD (Maxtor)
nVidia RAID (in mb)
P.S. I wery SORRY with my poor language!I'm going to blame the nVRAID because I've seen issues with it in the past. If your motherboard has another non-nVidia RAID solution, use that instead. Using the nVidia SATA ports as BASE or JBOD is fine and dandy but RAIDing always had issues. It's not even a driver issue I think it's just instability. Latest drivers and even boxed drivers never helped. Granted, some will report success with their rig. But on a professional level I've seen nForce issues on different motherboards and different hard drives that had RAID disaster stories.
Good luck and if you don't have another RAID solution, my suggestion would be to buy a dedicated RAID controller card.
LPB -
HELP NEEDED WITH ADDAPTER-DVI TO VGA.
PLEASE ...HELP NEEDED WITH WIRING CROSS OVER....CAN YOU HELP WITH BACK OF PLUG CONNECTIONS...I SORTA UNDERSTAND THE PINOUTS BUT CANT MAKE AN EXACT MACH...WOULD LIKE TO BE 100% SURE...
......THIS ENSURES NO SMOKE!!!
THE CARD IS AN ATI RADEON RX9250-DUAL HEAD-.........ADDAPTER IS DVI(ANALOG)MALE TO VGA(ANALOG)FEMALE.
ANY HELP VERY MUCH APPRECIATED........ SEEMS YOU NEED TO BE ROCKET SCI TO ATTACH A BLOODY PICTURE...SO THIS HAS BEEN BIG WASTE OF FING TIME!Quote from: BOBHIGH on 17-December-05, 09:21:31
Get over it mate !
I find it easy t read CAPS...and if you dont like it ...DONT READ IT!
And why bother to reply...some people have nothing better to do.
Yes there chep and easy to come by...Ive already got a new one.
All I wanted was to make a diagram of whats inside the bloody thing...it was a simple question and required a simple answer.
NO NEED TO A WANKA !!
I feel a bann comming up.
Have you tryed Google ? really.. your question is inrelevant. No need to reply indeed.
Why do you come here asking this question anyway ? is it becouse you have a MSI gfx card ? and the adapter has nothing to do with this ?
You think you can come in here yelling.. thinking we have to put up with it and accept your style of posting. This is not a MSI tech center.. it's a user to user center.. Your question has nothing to do with MSI relavant things anyway's.
Google = your friend.
Quote from: BOBHIGH on 17-December-05, 09:21:31
it was a simple question and required a simple answer
Simple for who ? you (buying a new one) ? me ? we ? .really...........
Quote from: Dynamike on 16-December-05, 04:11:48
1: There are allot of diffrent types of those adapters.
If any of the mods have a problem about my reply.. please pm me. -
Help needed for grouping.
Hi,
Help needed .
I have an internal table having 6 .
Ex :
f1 f2 f3 f4 f5 f6
a aa 11 p1 10 10
a aa 12 p1 20 20
b aa 11 p2 30 30
b aa 12 p2 40 30
Now i want to sum the fields f5 and f6 individually and need to display based upon the fields f1 and f4.
To Display :
f1 f2 f3 f4 f5 f6
a aa 11 p1 30 30.
b aa 11 p2 70 60.
can anyone help me.How to do this..?
ThanksHere you go
DATA:
BEGIN OF cur_tab OCCURS 0,
f1 TYPE c,
f2(2) TYPE c,
f3(2) TYPE c,
f4(2) TYPE c,
f5(2) TYPE c,
f6(2) TYPE n,
END OF cur_tab.
DATA:
BEGIN OF sum_tab OCCURS 0,
f1 TYPE c,
f4(2) TYPE c,
f5 TYPE p,
f6 TYPE p,
END OF sum_tab.
DATA:
BEGIN OF final_tab OCCURS 0,
f1 TYPE c,
f2(2) TYPE c,
f3(2) TYPE c,
f4(2) TYPE c,
f5(5) TYPE c,
f6(5) TYPE c,
END OF final_tab.
START-OF-SELECTION.
cur_tab-f1 = 'a'.
cur_tab-f2 = 'aa'.
cur_tab-f3 = '11'.
cur_tab-f4 = 'p1'.
cur_tab-f5 = '10'.
cur_tab-f6 = '10'.
APPEND cur_tab.
cur_tab-f1 = 'a'.
cur_tab-f2 = 'aa'.
cur_tab-f3 = '11'.
cur_tab-f4 = 'p1'.
cur_tab-f5 = '20'.
cur_tab-f6 = '20'.
APPEND cur_tab.
cur_tab-f1 = 'b'.
cur_tab-f2 = 'aa'.
cur_tab-f3 = '11'.
cur_tab-f4 = 'p2'.
cur_tab-f5 = '30'.
cur_tab-f6 = '30'.
APPEND cur_tab.
cur_tab-f1 = 'b'.
cur_tab-f2 = 'aa'.
cur_tab-f3 = '11'.
cur_tab-f4 = 'p2'.
cur_tab-f5 = '40'.
cur_tab-f6 = '30'.
APPEND cur_tab.
LOOP AT cur_tab.
MOVE-CORRESPONDING cur_tab TO sum_tab.
COLLECT sum_tab.
ENDLOOP.
LOOP AT sum_tab.
READ TABLE cur_tab WITH KEY f1 = sum_tab-f1
f4 = sum_tab-f4.
IF sy-subrc NE 0.
WRITE:/ 'Something went very wrong'.
CONTINUE.
ENDIF.
MOVE-CORRESPONDING cur_tab TO final_tab.
MOVE-CORRESPONDING sum_tab TO final_tab.
APPEND final_tab.
ENDLOOP.
LOOP AT final_tab.
WRITE:/1 final_tab-f1,
AT 5 final_tab-f2,
AT 10 final_tab-f3,
AT 15 final_tab-f4,
AT 20 final_tab-f5,
AT 25 final_tab-f6.
ENDLOOP.
and the output
a aa 11 p1 30 30
b aa 11 p2 70 60 -
Help needed on installation of Oracle 9i on Sun Solaris 8
Hey,
Help needed on installation of Oracle 9i EE on Sun Solaris 8. The problem I met was: we followed the installation guide from the documentation. And we selected the choice "install software only". After it was done successfully, we run Database Configuration Assistant utility to create a database instance. But finally it always tried to create the instance at the root directory ( / ) which doesn't have enough space and then failed. The case was that we have set the enviroment parameters: $ORACLE_BASE = /export/mydata, $ORACLE_HOME = /export/apps/oracle9i. That means it should be installed at /export/mydata, but it didn't. Any help or advice are welcome. Thanks.
SimonI have downloaded Oracle 11G R2 version from Windows and extracted it in Windows and copied it into DVD after extraction in two folders. Now I am mounting that DVD in Solaris 10 installed in my VMware . I made a new directory named as 'installation ' under /export/home/oracle and copied the folders from DVD to 'installation' folder. Now I am entering installation folder and try to do ./runInstaller as 'oracle ' user and getting the error mentioned before.
Edited by: 916438 on Mar 31, 2012 5:55 PM -
Help needed on installation of Oracle 9i EE on Sun Solaris 8
Hey,
Help needed on installation of Oracle 9i EE on Sun Solaris 8. The problem I met was: we followed the installation guide from the documentation. And we selected the choice "install software only". After it was done successfully, we run Database Configuration Assistant utility to create a database instance. But finally it always tried to create the instance at the root directory ( / ) which doesn't have enough space and then failed. The case was that we have set the enviroment parameters: $ORACLE_BASE = /export/mydata, $ORACLE_HOME = /export/apps/oracle9i. That means it should be installed at /export/mydata, but it didn't. Any help or advice are welcome. Thanks.
SimonI have downloaded Oracle 11G R2 version from Windows and extracted it in Windows and copied it into DVD after extraction in two folders. Now I am mounting that DVD in Solaris 10 installed in my VMware . I made a new directory named as 'installation ' under /export/home/oracle and copied the folders from DVD to 'installation' folder. Now I am entering installation folder and try to do ./runInstaller as 'oracle ' user and getting the error mentioned before.
Edited by: 916438 on Mar 31, 2012 5:55 PM -
Help needed in Finding Download location for Sun One Portal 7
Hi,
help needed for finding download location for Sun ONE Portal 7. I tried to find in Oracle Download page ,
http://www.oracle.com/us/sun/sun-products-map-075562.html, But unable to find.
Please share the link for download location.
I am totally new in Sun ONE Portal.
Thanks,
Edited by: 945439 on Oct 5, 2012 3:41 AMtry edelivery.oracle.com under sun products.
Maybe you are looking for
-
Adobe Premiere Pro CC 2014.2 Playback Freezing, Audio Dropouts
There are several times when I'm working on a project, whether small, medium or large in size, where playback tends to seize up my entire machine and everything locks up/freezes for 3-5 seconds. Then when it starts to play again, I get the audio dro
-
Can I download a progran (Nitro pro 7) onto my mac pro notebook when it says it's for windows? If so do I choose the 32 or 64 bit version?
-
Flash installation - fatal error. solaris installation program exited
Not very helpful to say the least. Seems to read the flar file and go through the upgrade and then come up with this error. Any ideas?
-
I clicked on a link to download a file and opened a blank tab
So I clicked on a link to download a pdf file then I went into the download arrow and I clicked on the file. When I clicked on the file it just opened a new blank tab. After try and try again I still can't get it to download the file correctly. I hav
-
MS Acess very slow perfromance...
Hello, I'm developing a java (swing) application which gets its data from an MS Acces database. It all works fine, but... very very slow. When I press a button to fill an Jlist with about 10 rows from the database, it easily takes up to 5 seconds and