How to realize print function in JSP

How to realize print function in JSP? I know use Javascript:window.print() can print,but it will print whole page,it don't fit me;Another method is to write JSP into Excel and then print it in Excel,but it don't fit me too,because it don't print directly. Anybody know how to print it directly?

Many websites offer a "printer friendly" version of a certain page. That IMO is the only way to solve your problem, next to using CSS to use a different style for printer output. Here is a tutorial that covers this:
http://www.alistapart.com/stories/goingtoprint/

Similar Messages

  • How to write printing function using JSP?

    dear all,
    i want to add a printing function in my project but i do not know how to do it? could anyone teach me how to do it?
    thanks
    eric

    salut eric,
    you can do it this way :
    1 - create a html link in your code to this javascript
    function : (I am using Struts, but you can write it in
    pure html
    <html:link href="#bodyStart"
    onclick="openWindowForPrinting()"
    titleKey="msg.status.print">      <bean:message
    key='app.print' />
    <script language="JavaScript">
    <!--
    window.open = SymRealWinOpen;
    //-->
    </script>
    </html:link>
    >
    >
    2 - here is the javascript function : it open a window
    with the "print.jsp" page.
    function openWindowForPrinting(){
    window.open('/your_project/pages/common/print.jsp','',
    'left=150, top=150 , status=no, directories=no,
    toolbar=no, menubar=yes, location=no, scrollbars=yes,
    resizable=yes, dependant=yes');
    3 : here is the print.jsp page : You have only to
    create a session variable called
    "currentBodyRelativeLocation", which content the
    relative URL to the page you want to print (for
    example, the boby of the current page).
    <%@ taglib uri='/WEB-INF/tlds/perso.tld'
    prefix='perso' %>
    <html>
    <head>
    <perso:csslink page='${cssRelativeLocation}' />
    </head>
    <body onload="var SymTmpWinOpen = window.open; window.open = SymWinOpen; printPage();; window.open = SymTmpWinOpen;">
    <body>
    <jsp:include page="${currentBodyRelativeLocation}"/>
    </body>
    <script language="JavaScript">
    <!--
    window.open = SymRealWinOpen;
    //-->
    </script>
    </html>
    <script language='javascript'>
    function printPage(){
    window.print();
    window.close();
    </script>
    hai,
    i'm not very understand how is your code work. when i write html code, do i need to mind about this code: "msg.status.print" ? what is this code mean?
    i have too much question on this thing. would you mind to be further explain to me? or is it any reference for me to refer? i'm really new to write printing function on JSP.
    i never write this function before. i'm feel so lost.....:(
    thanks again
    eric

  • How to achieve print functionality in OA Framework page

    Hi All,
    I have created one page in OA Framework.
    There is one print button on page for printing the page
    How to achieve print functionality thruoug Print button in OA page.
    Please help me in this if some one has use thif functionality before or if someone knows about it.
    Thanks
    Nisha

    Hi Nisha,
    Have u checked out "printable page" in OA Developer guide??
    Step 1: Add a page-level button as described in the Buttons (Action/Navigation) document.
    Step 2: Assuming your button label is the standard "Printable Page," apply the OA Framework attribute set /oracle/apps/fnd/attributesets/Buttons/PrintablePage.
    Step 3: Set the button's Destination URI property to point to the current page and set the UIX facet parameter (OARF) to printable as shown in the following example (if you don't know what a "facet" is, please see Controlling UIX Rendering Output for additional information). Remember to retain your application module.
    OA.jsp?page=<CURRENT_PAGE>&retainAM=Y&OARF=printable
    Step 4: Set the button's Target Frame property to _blank. This ensures that the printable page opens in a new window.
    Regards,
    Devang

  • How to realize "print preview" in Flex?

    I checked the sample in Flex Help on printing with Flex. How can I realize "preview" function?
    Thanks!

    Many websites offer a "printer friendly" version of a certain page. That IMO is the only way to solve your problem, next to using CSS to use a different style for printer output. Here is a tutorial that covers this:
    http://www.alistapart.com/stories/goingtoprint/

  • How to create download function in JSP?

    Can I know how to make a download function in JSP? Any sample?. Thank You very much!

    http://forum.java.sun.com/thread.jspa?threadID=5312541&tstart=0
    Sorry but whining about it in duplicate threads doesn't help.
    HELP DENIED!

  • How to implement this function in JSP/Servlet env?

    Hi all,
    I working on a project, it provides functionality to upload file using JSP/Servlet. In the first JSP page, there is file location and submit button. After user select a file to upload and click submit button, a message, like "sending file to XXXX", will be shown on the screen. Once uploading and validation are done on the server-side, a successful/error msg will be shown to user.
    Here I have a question for the "sending..." msg and the successful/error msg. They should be put in one jsp page or in two separate page? how to implement them?
    Thanks for any help!
    Tranquil

    For the sending message... Well, the thing is, when you click submit, it's sending the file to the server and the server is processing it, and this is all done before the "complete" page is sent to the server. So one would need to use some Javascript on the page before the actual submit happens to show some message. This is done on Ebay when you put something for sale, you can upload an image, and there is a little popup message telling you that it's uploading, and it is removed when the process is done. Now, I'm not sure the exact details of how this works, but my educated guess is this:
    1) The onsubmit function of the form checks that the file upload fields have a value (no need to popup a message if no file upload, since that's what usually takes the time, although it could just be assumed there is a file). If a file is to be uploaded, or just want to show the message anyway, a new popup window is opened with the window.open method and the "sending" message is shown (either written via Javascript or just load a small web page to the window).
    2) The popup window, since you can't transfer the window object from the form page to the next page, has to check window.opener for some value that the success/error page would have to set. The success/error page could use it's body onload function to set a variable in it's own window object to denote that the page is loaded. The popup window can use a looping check using setTimeout or setInterval in Javascript to check for window.opener.isLoadedVariable to be present, and if so, close itself.
    I've never done that, but I see no reason why it wouldn't work.

  • How to define recursive functions in JSP

    Hi,
    If anybody knows, how to to define recursive functions pls help. I am using an XML file for the creation of a tree menu. In order to display the menu, i have to use recursive functions...Also out.println throwing error in the function..
    Thanks,
    Philips

    I do not have my Java book at work with me today so you'll have to bear with me. The following routine assumes that you can get some sort of branch object from your tree menu object (also assuming you have something like this). Furthermore, it assumes that the branch object can return some sort of collection of all leaves and branches on a particular branch through a made-up getLeaves() method call.
    <%!
              public void displayLeaves(Branch branch)
                   Iterator branches = null;
                   branches = branch.getLeaves().getIterator();
                   Object leaf = null;
                   while( branches.hasMoreItems() )
                        leaf = branches.nextItem();
                        if(leaf instanceof branch)
                             displayLeaves((Branch) leaf);
                        else
                             out.println( ((Leaf)leaf).getValue() );
    %>This code fragment should be just the logic you need to expand a tree as JSP output. To invoke this method all you have to do is pass the root branch element to the method from within your JSP. Please let me know if you need additional info.

  • How to call userdefined function in JSP

    Iam writing my own method in JSP ,how to call that method.
    thanks in advance
    thanks
    -RR-

    <%!
    static void sayHello(ServletOutputStream out){
    out.print("Hello");
    }%>
    <%
    sayHello(response.getOutputStream());%>
    You method can either be static or not, but in both case avoid instance/static variables as you will get concurrency issues
    if you use tomcat, take a look in tomcat/work/catalina/_localhost/org/apache/jsp
    open the .java file generated by the container and you will quickly understand how this works

  • Hello everyone,I have a question,how to realize trigonometric function:sin

    I need to use sin to calculate the distance between two points on the earth.
    In orcale it has the functions:SIN,ACOS,SQRT, but in TT the same sentence is wrong.
    Now I have a question:how can I realize SIN.
    Thanks

    Hi 948835,
    TimesTen doesnt have a lot of math functions, therefore you can use the following options:
    - calculate math functions (sin, cos and etc.) on application level. Different programming languages contain a very rich functional for math ( look at java.lang.Math for Java for instance).
    - use "Passthrough" TimesTen feature which provides you an opportunity to execute the query in Oracle instead of TimesTen. It works for In-Memory DB Cache only :(
    Best regards,
    Gennady

  • How to disable print functionality in Dashboard

    Hi i want to disable the print pdf functionality in the dashboard, how to do this?
    Thanks in advance...

    I understand what you mean. I had the same problem, but I was able to limit print to whole dashboard, not request by request.
    1. You can try add logo in title of request that you would like to print. PDF and print control is setting printing of whole dashboard, not request.
    2. Or if you have more request in dashboard you can set "Collapsible" option on each request, so that user can choose which request he would like to print with logo (header). If you are using this method you must disable print option on every request, and allow only printing the whole dashboard.
    If I haven't explain in understandable way please let me know, I will try to explain it again.
    Hope it will help

  • How to realize the function like SDO_GEOM.SDO_BUFFER in Spatial Operators?

    Dear all,
    I wanted to use SDO_GEOM.SDO_BUFFER function to generate a
    buffer polygon around a geometry object while it is pretty slow
    to perform for a large spatial database. I think it better
    to use Spatial Operators for it takes advantage of spatial index.
    But within operators, there are no availble function. Can anyone
    tell me how to do it with Spatial Operators?
    Thanks a lot,
    Fan

    Fabio,
    Error 13349 indicates that the polygons intersect with themselves.
    You need to fix these errors. There are tools in MapInfo Professional 7.5 to check and automatically fix them. There are other tools commercially available which also fix geometry errors.
    If you know MapInfo I would fix these errors there.
    Ivan

  • How to use print functionality in Java Studio Creator

    Hi,
    I am working on one JSF project using Java Studio Creator.
    I have requirement where I have one table and print button.
    By clicking the print button, I want the contents of table to be printed.
    I have configured all the required properties of this button but still by clicking this print button, I am not able to see the print window.
    Please help me in that, Its urgent.
    Thanks in advance.
    Vijay

    Hi,
    i think the best thing for you to do is to use javascript. go to jsp page of the form and find the button, as part of its attribute type onClick="window.print()"

  • How to realize the function only a validator is fired when submit

    Sorry for my question.
    In a web Page here are a inputText of a code ,a search button Searching by the Code , others inputText s and a 'OK ' button.
    the question is how to fired a only 'code' validator when searching
    I made the search button immediate="true" ,So I wanted to fire the code validator by actionListener, the others validator were not fired .
    But in this way i find i can't get the code's number not only by binding
    but also by value. so What shall i do?
    the actionListener is this:
         public void commandButton_search(ActionEvent e){
              UIViewRoot UIroot=FacesContext.getCurrentInstance().getViewRoot();
              UIComponent uicomponent=UIroot;
              String strCode= (String)this.inputText1.getValue();
    MemberValidator aValidator=new MemberValidator();
              aValidator.searchAddressCheck(uicomponent,strCode);

    As I posted before a response for your post,
    if you want to use the input value in an action,
    you should not use immediate="true";
    otherwise you need to do everything JSF will do.
    The most simple way is to have two <h:form>s in the page.
    One <h:form> includes the <h:inputText> of a code and the search button.
    Another <h:form> includes other components.
    If the OK button also use the seach code, you can use Javascript to copy the
    code value from the <h:inputText> in the first form to some <h:inputHidden>
    in the second form.

  • How to write a function in JSP

    I have a few lines of code I would like to store in an external file and then call it from a web page.
    Here is the code
         String isCE = "No";
         String ismobile = "No";
         String accept = request.getHeader("accept");
         String user_agent = request.getHeader("user-agent");
         String accept_charset = request.getHeader("accept-charset");
         String accept_language = request.getHeader("accept-language");
         String profile = request.getHeader("profile");
         String x_wap_profile = request.getHeader("x-wap-profile");
         if (user_agent.contains("CE")) {
              isCE = "Yes";
         if (x_wap_profile == null && isCE == "No") {
              response.setStatus(301);
              response.sendRedirect("someurl.com");
              response.setHeader( "Connection", "close" );
    Now I would like to include this code and then call it with a single function and then pass the url like:
    snif("www.someurl.com");
    Please help

    Thai,
    You can use the "channel" functions for this. I'm far from an expert on channel programming but I've read files line-by-line successfully by going one character at a time, looking for a carriage return.
    You can open up the file channel with something like:
      ChannelT chan;
      FilePathT *path;
      UCharT ptr[1];
      IntT numRead;
      path = F_PathNameToFilePath("C:\\temp\\mydoc.txt", NULL, FDefaultPath);
      if((chan = F_ChannelOpen(path,"r")) == NULL)
          return;
      //read the first character
      numRead = F_ChannelRead(ptr, sizeof(UCharT), 1, chan);
    ...then you can call F_ChannelRead iteratively to build the string in a buffer, looking for a carriage return (ASCII 13) and stopping there. (that is, ptr[0] == 13).
    There might be a better way. This is just the way I've gotten it to work. It probably is not a good method for unicode files.
    Russ

  • How to realize the functionality like the JLayer in Swing?

    JLayer in Swing is a decorator for Swing components. It enables us to draw on components and respond to component events without modifying the underlying component directly, which is interesting  to me. How to do that in JavaFX?

    Technique Description - Use a StackPane
    For simple layering, wrap the underlying node in a StackPane and add further nodes to the stackpane to layer them on top.
    One technique is to just use two nodes in the StackPane, the original node and a Pane on top the original node.  Because the Pane is a automatically resizable Node, the Pane size will adjust to completely cover the Node below. By setting the pickOnBounds and mouseTransparent properties of the Pane appropriately, you can decide whether you want to top pane to consume all mouse events, consume only mouse events on the areas where the top Pane is not transparent and let the rest pass through to the underlying node or let all mouse events be handled by the underlying node.  The top pane is sometimes known as a glass pane.
    Links to examples which use the described technique
    A very simple example with no input processing is =>
    javafx 2 - How to implement a transparent Pane with non-transparent children? - Stack Overflow
    A more comprehensive demonstration of the technique is han solo's blog post on using a glass pane for processing =>
    http://harmoniccode.blogspot.com/2013/04/validate-it.html
    For a supported library by a commercial company see the Decoration Utilities from JideFX =>
    Highlights of the JideFX Beta Release (2 of 3) | David Qiao's Blog
    Suggested Approach
    If you just have one-off requirements than rolling your own like in the StackOverflow answer or han solo's blog is the way to go.
    If you have more sophisticated requirements, you should look into JideFX (it is an open source library).
    And I hope I've got this answer right because I've never used JLayer in Swing, but it appears similar to what I have described.

Maybe you are looking for