Printing data in servlet
hello everyone,
I am trying to print some data on a servlet page by using the following code:
String s1="My name";
PrinterJob job=PrinterJob.getPrinterJob();
Book book = new Book();
book.append(new Printer("<html>\n<body>This is a test2</body></html>"), new PageFormat());
job.setPageable(book);
boolean doPrint = job.printDialog();
if (doPrint) {
try {
job.print();
} catch (PrinterException exception) {
System.err.println("Printing error: " + exception);
out.close();
it works when I test it with the above code but I get the following error when
I apply my own data:
java.lang.NullPointerException.
Basically the data I am applying to in not being carried over when I click the button to click:
The data I am using is:
String[] itmcod=request.getParameterValues("itemcd");
String[] itmnm=request.getParameterValues("itmname");
String[] itmdes=request.getParameterValues("itmdescrip");
String[] itmcolor=request.getParameterValues("itmcol");
String[] itmsi=request.getParameterValues("itmsize");
String[] itmprice=request.getParameterValues("itmpri");
Collpointorder collpointorder=new Collpointorder(itmcod, itmnm, itmdes, itmcolor, itmsi, itmprice);
out.println(collpointorder.toString());
out.println("<form method='get' action='vieworderser'>");
out.println("<input type='Submit' value='printord' name='Print Order'/>");
String prrequest=request.getParameter("printord");
if(prrequest==""){
String[] itmcod1=request.getParameterValues("itemcd");
String s1="My name";
PrinterJob job=PrinterJob.getPrinterJob();
Book book = new Book();
//book.append((s1), new PageFormat());
for (int i=0; i<=itmcod.length; i++){
//book.append(new Printer(" "+ itmcod1 + s1 + " " + itmcod[i] + " " + itmnm + " " + itmdes ), new PageFormat());
book.append(new Printer(" "+ itmcod1 + s1 + " "), new PageFormat());
//+ itmcod[i] + " " + itmnm + " " + itmdes ), new PageFormat());
//book.append(new Printer("<html>\n<body>This is a test2</body></html>"), new PageFormat());
job.setPageable(book);
boolean doPrint = job.printDialog();
if (doPrint) {
try {
job.print();
} catch (PrinterException exception) {
System.err.println("Printing error: " + exception);
}//end of if
}//end of loop
from the URL:
Before I click the button to printer, the URL is like:
vieworderser?itmname=asdf&itmdescrip=sdf&itmcol=sdzfa&itmsize=asdf&itmpri=asdf&itmdept=Collection+Point&itemcd=5475686&itmname=asdf&itmdescrip=asdf&itmcol=sdf&itmsize=qfasdf&itmpri=sdf&itmdept=Collection+Point&itemcd=857587&itmname=null&itmdescrip=null&itmcol=null&itmsize=null&itmpri=null&itmdept=Collection+Point&itm=itm
After clicking the button to print, the URL:
vieworderser?Print+Order=printord
I have tried using another servlet and also if statements:
So it clears away the data. I am not very familiar with the java printing api, so if anybody have any suggestion, please, pass on.
Thanks
eve
Sorry,
I might this code:
package servlet;
import StockInformation.Collpointorder;
import StockInformation.Printer;
import java.awt.print.Book;
import java.awt.print.PageFormat;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
import java.io.*;
import java.net.*;
import javax.servlet.*;
import javax.servlet.http.*;
* @author y.kwarteng
* @version
public class vieworderser extends HttpServlet {
/** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
* @param response servlet response
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet vieworderser</title>");
out.println("</head>");
out.println("<body>");
out.println("<form method='get' action='vieworderser'>");
String[] itmcod=request.getParameterValues("itemcd");
String[] itmnm=request.getParameterValues("itmname");
String[] itmdes=request.getParameterValues("itmdescrip");
String[] itmcolor=request.getParameterValues("itmcol");
String[] itmsi=request.getParameterValues("itmsize");
String[] itmprice=request.getParameterValues("itmpri");
Collpointorder collpointorder=new Collpointorder(itmcod, itmnm, itmdes, itmcolor, itmsi, itmprice);
out.println(collpointorder.toString());
String[] itmcod2=collpointorder.getitmid();
//out.println("<form method='get' action='vieworderser'>");
out.println("<input type='Submit' value='printord' name='Print Order'/>");
String prrequest=request.getParameter("printord");
if(prrequest!= null && prrequest.equals("Print Order")){
try{
//RequestDispatcher dispatcher = getServletContext()
//.getRequestDispatcher("/printorderser");
//dispatcher.forward(request, response);
for (int i=0; i<=itmcod.length; i++){
out.print("this is the itemcode" +itmcod);}
}catch(Exception ex){
System.err.println("Can not show the print page");
//if(prrequest!=""){
String[] itmcod1=request.getParameterValues("itemcd");
String s1="My name";
PrinterJob job=PrinterJob.getPrinterJob();
Book book = new Book();
//book.append((s1), new PageFormat());
for (int i=0; i<=itmcod1.length; i++){
//book.append(new Printer(" "+ itmcod1[i] + s1 + " " + itmcod[i] + " " + itmnm + " " + itmdes ), new PageFormat());
book.append(new Printer(" " + itmcod1[i] + s1 + " "), new PageFormat());
//+ itmcod[i] + " " + itmnm + " " + itmdes ), new PageFormat());
//book.append(new Printer("<html>\n<body>This is a test2</body></html>"), new PageFormat());
job.setPageable(book);
boolean doPrint = job.printDialog();
if (doPrint) {
try {
job.print();
} catch (PrinterException exception) {
System.err.println("Printing error: " + exception);
}//end of if
}//end of loop*/
/**try{
RequestDispatcher dispatcher = getServletContext()
.getRequestDispatcher("/printorderser");
dispatcher.include(request, response);
}catch(Exception ex){
System.err.println("Can not show the all items page");*/
out.println("<h1>Servlet vieworderser at " + request.getContextPath () + "</h1>");
out.println("</body>");
out.println("</html>");
out.close();
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/** Handles the HTTP <code>GET</code> method.
* @param request servlet request
* @param response servlet response
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
/** Handles the HTTP <code>POST</code> method.
* @param request servlet request
* @param response servlet response
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
/** Returns a short description of the servlet.
public String getServletInfo() {
return "Short description";
// </editor-fold>
Thanks
eve
Similar Messages
-
Print Layout Desigener print date
Dear all,
In our Balance Report we want to fill in the Print Layout the Print Date.
is there a possibility for filling this?
The path of balance report is :
Financials__ Financial Reports__ Financial__ Trial Balance
Thank you and best regards to all!!
SerkanHi Nat,
thank you for your fast and helpfull support.
it works
regards
Serkan -
Print Date issue in Dunning Correspondence
Hi,
I have an issue with Print Date in Dunning correspondence. The dunning proposal and activity run has happened. The correspondence printing will fetch the accounts from the database as per the print date.
1. I would like to know where and how the dunning activity data stored?
2. Where and How the Print date assigned for accounts which helps FPCOPARA to retrieve accounts on that particular date?
Please HELPHello Joe,
I still have the issue with this print date.
I have given only cores type and as u said the real print.
when i checked the corrhist for a particular CA, different times different future date has come.
For eg: date is issue: 12/01/2009 (mmddyyyy) printdate is 12/20/2009.
10/01/2009 10/15/2009
like this, many cust have this issue.
why this prind date for some CAs are different or future dates?
where the settings for this print date will be?
Because of this, on a particular day all the dunned CAs are not picking up for Correspondence printing. these excepted CAs will come on another future day printing.
please share some ideas to solve this issue
Regards,
Sunitha -
How to print Data Model in Report??
Do anyone know how to print Data Model??
Thanks your help.
- FrankHi Venkat,
Thanks alot.... i am checking the appendix k.
I want to know that if i want to customize the report as per the client requirement,
can you please let me know which template i will use if i required remittence advice as well as check print data on the layout.
The following is the list of field i required:
Vendor ID
Check Date
Check number
invoice date
invoice/ CR memo number
invoice description
invoice gross amount
invoice discount amount
invoice net amount
total gross amount
total discount amount
total net amount
logo
company name and info
bank name and info
check number
check amount spelled out
check date
check amount numeric
payee name
CEO signature
MICR check number
MICR routing number
MICR bank account number
mailing return address
mailing address
Venkat it would be great help if you please let me know the exact process to be follow for check printing report.
I worked on bi publisher report in 11i, but in 12i the process is bit different.
also if you have any template ready can you please send me on my mail id ... i forwarded you the test mail from my official id or on [email protected]
Looking forward to your kind response.
Regards
Ratnesh -
How to print date & time in photos
Thanks for the help.
I need to print either photos with time and dates in them... or the Bridge contact sheet with date and time info.
The final printed image will be used in court to photo document evidence.
Do I have to do a screen capture or is there some other way?
My camera will not allow me to imprint time and date.
I'm using CS4 on both Windows and Mac.
Thanks again in advance for the taking the time to help.
Dances With Pixels
I may have sent this twice, but I'm new to this and this is my first time trying to post.Thank you for taking the time to respond. Much appreciated.
And will follow up on your suggestions.
Date: Tue, 10 Aug 2010 23:55:31 -0600
From: [email protected]
To: [email protected]
Subject: How to print date & time in photos
I think there are (various) Scripts about for that.
For example addExifDate1.5.jsx:
http://www.adobe.com/cfusion/exchange/index.cfm?event=extensionDetail&extid=1346521
One should be able to adapt it to include the time.
You could ask in the Photoshop Scripting Forum or http://www.ps-scripts.com/
> -
Pages 08: No "print date"?
I am just testing iWork '08 and hope to replace MS Office soon. In MS Word documents I am used to set dates as date of printing ("Insert > Field > Date > PrintDate"). This comes very handy, because I usually want to have the date of the day when the document was printed shown in my letters. As a secondary effect, when opening a document later, I see exactly when the document has been created or printed, because the print date remains in the document unchanged (until I would print it out again).
In Pages 08 I do see how to insert a date field ("Insert > Date/Time"), but I'm only able to adjust this to the actual date. Does Pages not offer any possibility to insert a PrintDate, like Word does?iCoco wrote:
Does Pages not offer any possibility to insert a PrintDate, like Word does?
Happily, as far as I know, nobody wrote that Pages is offering all the features available in Word.
You met one of the missing one.
If you wish to insert a fixed date, the response was given several times and a simple search in the existing threads would have point to the thread.
The first returned thread contains the response which is:
use the free WordService from the site:
http://www.devon-technologies.com/products/freeware/services.html
Yvan KOENIG (from FRANCE mercredi 9 juillet 2008 19:31:16) -
Dispaly Printing Details like printing date
Hi
Does any know if there is an option to display/print in every report
the printing details like printing date , title , page , and input parameters fields
Thanks in advance
RegardsPAGE : &SFSY-PAGE& OF &SFSY-FORMPAGES&
DATE : &SFSY-DATE&
TIME : &SFSY-TIME&
USER LOGON : &SFSY-USERNAME&
kishan negi -
How can i print data in bi publisher template across wise
Hi,
Please let me know how can i print data in bi publisher template across wise.
eg.
In my C1 field there is a data coming like
S
JR
MR
i want to print this filed
S JR MR
Thanx
ArjunHi ,
Now i am able to print S JR MR horizontally.Thanx a lot for that.Now my problem is
There is one column field which displaying value like S JR MR
Now i am calculating a value using a function and want to display that value for each vale of above column
For eg
The report should display like this
C1 C2 C3
45 1-2-3 S JR MR
45*1 2*45 3*45
I have created package to make the string 1-2-3 separeate and the fuction is working fine .But unable to print value in bi
Its displaying like this for each S JR MR
45*1 2*45 3*45 45*1 2*45 3*45 45*1 2*45 3*45
45*1 is in different group that should display also horizontally thats why i tried this <?for-each@cell:G_STR_ID?>
Please help me
Thanks in advance -
How to print date & time stamp on photos?
How to print date & time stamp on photos?
Three methods:
File>process multiple files>labels. Be sure to uncheck "same as source", or the originals will be overwritten. It is best to work on duplicate files, esp. while learning.
Use the horizontal or vertical type tool to add the information manually to each picture file
If the same information is to be applied to several pictures, e.g. a copyright notice, use of a brush made in PSE is very efficient -
How to print date/time in report page footer?
Hi
I have a report which users can print as PDF.
However, I like to display current date/time in report footer.
I can see the Page Footer in section but can't figure out how to print date/time there.
Thanks for help.hi movilogo
Please try this.
Create hidden item P1_DATE
Create On load process in page 1 and put this code
begin
:P1_DATE:=TO_CHAR(SYSDATE,'DD-MON-YYYY HH:MM:SS');
end;
Open your region in Page 1 put this code in Footer area
*&P1_DATE.*
Refresh your page.
you will get the output like this.
16-SEP-2009 11:09:17
thanks
Mark Wyatt -
How to get javabean data in Servlets.( JavaBean -- Servlet(Controller)
how to get javabean data in Servlets.
1) I am using name ,password in Jsp(View )
2) when I submit this Bean will be called and Setter methods will be called .
3) In ServletController (controller) I want to get data of javabean.
In this I have to do validation of user.
I want to pass the javabean obj as like -->
request.getAttribute("beanObj");
My intention is to get all the poperties in javabean by passing bean id
or beanobj ,
Is there any way to get all the data using bean id or beanObj.
Plz Reply,Now in the Servlet we can get the same bean by this code:
PageContext pageContext = JspFactoryImpl.getDefaultFactory().getPageContext(this, request, response, null, true, 8192, true);
UserBean userbean = (UserBean)pageContext.getAttribute("userbean", PageContext.SESSION_SCOPE);
String userid = userbean.getUsername();
For this code to work it is needed to import 2 files:
import org.apache.jasper.runtime.JspFactoryImpl;
import javax.servlet.jsp.PageContext;
The JspFactoryImpl is in jasper-runtime.jar file provided in tomcat dir.It seems to me that you are exactly knowing what you are doing :-(
You can get a Bean stored in a Session by
request.getSession().getAttribute("userbean");
In the login.jsp page for example we have the code
<jsp:useBean id="userbean" scope="session"class="com.newproj.UserBean" />
<jsp:setProperty name="userbean" property="*" />the jsp:setProperty is not called when you click on the submit button
if fills the bean with the request values from the previous request.
andi -
'unable to send print data' on HP Laserjet 1536dnf MFP
Hi there,
I'm running an iMac with OSX 10.6.8. Via an USB cable I have attached a HP Laserjet 1536dnf MFP to the iMac.
I also use this printer to print via wifi (i.e. through the iMac) with my MacBook Pro (with OSX 10.7.3).
Suddenly today the printer stopped working via my MacBook Pro. I get an error message: 'unable to send print data'.
I have checked my antivirus etc., but that does not appear to be the problem. I have also updated the firmware of the printer, without success.
Can somebody help me out? Is the OS difference the problem? But until today that hasn't been a problem.
Thank you very much! Regards, Luc.Hi jemenake
I understand you lost connection with the network for the Laserjet 1536 through ethernet connection.
Disconnect the routers power cable, wait 10 seconds, then reconnect the power cable. Wait till it's ready. The router might not be finding the printer on the network.
If this doesn't resolve the issue continue to the next steps.
Print a configuration report from the LaserJet 1536dnf.
Press the Setup button, (the one with the wrench on it)
reports, press OK, Config Report, press OK.
Check to see if the ip address is valid.
If you have a valid ip address then delete and add the printer on the mac, the driver might have become corrupted.
Delete printer on mac.
Click on the Apple, click System & Preferences,then click the Print & Scan icon (on some systems this may be displayed as Print & Fax),highlight your printer name and click the button on the bottom left corner of the screen.
Add printer on the mac.
Click on the Apple, click System & Preferences, and then click the Print & Scan icon (on some systems this may be displayed as Print & Fax),click add a printer, then select the printer from the list, make sure the printer listed beside use or print: shows proper printer name and not airprint, (airprint is a preinstalled apple driver with basic funtionality if on 10.8) add it in.
If the ip address is not valid please let me know.
Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
Click the “Kudos Thumbs Up" on the right to say “Thanks” for helping!
Gemini02
I work on behalf of HP -
How to print date in cheque box in sapscript??
Hello Guru,
We have developed or design new form for cheque printing in sapscript
how to print date in cheque box in sap.
1
6
1
2
2
0
1
1
thanks in advance.
Thanks & Regards
Richahi,
If your requirement is to display date with box,first create a Box by using following syntax
* &sy-datum&
/: BOX XPOS '0' CH YPOS '3.65' LN WIDTH '77.50' CH HEIGHT '4.5' LN FRAME '10' tw
then adjust the box size according to your requirement by changing xpos,ypos,width and height
with regards
Edited by: naresh bammidi on Dec 16, 2011 8:00 AM -
how to print data in the following format
"CCMMDDYY"hi
good
yes you can very much print in that format, just follow this process
1-declare 4 strings
2-store all the different type of data in different variables
3-concatenate them and store them in a different variable
4-display tht varibale which contain that concatenate value
thanks
mrutyun^ -
Print data at new line in SAP Scripts
Hi,
Is there any way that i can print data at new line in sap scripts. I am looping my data and its printing in the same line but i need to print it at new line. Is there any formating options or any command to do that.
ThanksThan you must take all the values from the internal table into the different variables and than print them.
In program:
READ TABLE ITAB INTO WA_TAB INDEX 1.
IF SY-SUBRC = 0.
VAR1 = WA_TAB-FIELD1.
ENDIF.
* read all the lines and fill the VAR variables
In SAPScript:
/E LINE_VAR
/P &VAR1&
/P &VAR2&
/P &VAR3&
/P &VAR4&
Regards,
Naimesh Patel
Maybe you are looking for
-
How do I change the duration of photos?
I have a series of approx. 20 photos that I would like to import into FCE in order to make a stop frame animation series... each photo about half a second each. How do I change the setting? Thanks.
-
STMS Configuration in Distributed environment
Hello , Is there any extra efforts involved to configure STMS in Distributed Installation (i.e ABAP CI reside on Host A & ABAP DB redide on Host B)? In my case DEV , QA & PRD ( CI & DB ) instalaled on indivisual servers. In STMS configuration there i
-
Select previous page items or next page items (IDCS3)
Hello all, How can I refer to previous page or its item? I am trying to do something below. if a textFrame with label "myFrame" is missing on current page go to next page (or may try to next page) for (var i=0; i<=myTotalPage-1; i++) app.activeWindow
-
Windows XP Embedded Secuirty Updates
I apologize if this is in the wrong place but I was unable to find a Windows XP Embedded category. I believe support for Windows XP Professional regarding security updates will end this year April 2014. Support for Windows XP Embedded lasts beyond t
-
Every time I go to bounce, Logic is crashing (8 times so far with 1 success). This is a very new problem and I don't think I have changed any settings within Logic itself. Any clue what I can do?