Jaseper with JSP coding

Hi frnds,
I need full coding for displaying Jasper report using JSP.
Kindly help me to sort out the problem.

You can write Java code in your JSP which looks up an EJB and invokes methods on it.
However it's better to use ordinary Java beans to do the EJB lookup and invocation, and access the Java beans from a JSP.

Similar Messages

  • Use of Threads with JSP's

    Can you use threads in a web application that uses JSP's plus Servlets and Beans ?
    We have a JRUN 3.1 application using JSPs, Servlets and Beans. Shortly after we went live it became apparent that any 2 users using the same object experienced problems as one object was overwriting another. In a panic the problem was solved by whacking SYNCHRONISED on all objects.
    Now we want to write another application, are there strategies for using Threads with JSPs?
    Would this be part of the webserver configuration or would the application be coded in a certain way ?
    Please can you give me a simplistic answer or point me to some documentation that gives a simple overview.
    Thanks Steve

    Hi,
    You can use thread with jsp, i am sending u a example
    package thread;
    import java.io.Serializable;
    public class TaskBean implements Runnable, Serializable {
    private int counter;
    private int sum;
    private boolean started;
    private boolean running;
    private int sleep;
    public TaskBean() {
    counter = 0;
    sum = 0;
    started = false;
    running = false;
    sleep = 100;
    protected void work() {
    try {
    Thread.sleep(sleep);
    counter++;
    sum += counter;
    } catch (InterruptedException e) {
    setRunning(false);
    public synchronized int getPercent() {
    return counter;
    public synchronized boolean isStarted() {
    return started;
    public synchronized boolean isCompleted() {
    return counter == 100;
    public synchronized boolean isRunning() {
    return running;
    public synchronized void setRunning(boolean running) {
    this.running = running;
    if (running)
    started = true;
    public synchronized Object getResult() {
    if (isCompleted())
    return new Integer(sum);
    else
    return null;
    public void run() {
    try {
    setRunning(true);
    while (isRunning() && !isCompleted())
    work();
    } finally {
    setRunning(false);
    And JSP page start.jsp
    <% session.removeAttribute("task"); %>
    <jsp:useBean id="task" scope="session"
    class="thread.TaskBean"/>
    <% task.setRunning(true); %>
    <% new Thread(task).start(); %>
    <jsp:forward page="status.jsp"/>
    ///////////////// status .jsp
    <jsp:useBean id="task" scope="session"
    class="thread.TaskBean"/>
    <HTML>
    <HEAD>
    <TITLE>JSP Progress Bar</TITLE>
    <% if (task.isRunning()) { %>
    <SCRIPT LANGUAGE="JavaScript">
    setTimeout("location='status.jsp'", 1000);
    </SCRIPT>
    <% } %>
    </HEAD>
    <BODY>
    <H1 ALIGN="CENTER">JSP Progress Bar</H1>
    <H2 ALIGN="CENTER">
    Result: <%= task.getResult() %><BR>
    <% int percent = task.getPercent(); %>
    <%= percent %>%
    </H2>
    <TABLE WIDTH="60%" ALIGN="CENTER"
    BORDER=1 CELLPADDING=0 CELLSPACING=2>
    <TR>
    <% for (int i = 10; i <= percent; i += 10) { %>
    <TD WIDTH="10%" BGCOLOR="#000080"> </TD>
    <% } %>
    <% for (int i = 100; i > percent; i -= 10) { %>
    <TD WIDTH="10%"> </TD>
    <% } %>
    </TR>
    </TABLE>
    <TABLE WIDTH="100%" BORDER=0 CELLPADDING=0 CELLSPACING=0>
    <TR>
    <TD ALIGN="CENTER">
    <% if (task.isRunning()) { %>
    Running
    <% } else { %>
    <% if (task.isCompleted()) { %>
    Completed
    <% } else if (!task.isStarted()) { %>
    Not Started
    <% } else { %>
    Stopped
    <% } %>
    <% } %>
    </TD>
    </TR>
    <TR>
    <TD ALIGN="CENTER">
    <BR>
    <% if (task.isRunning()) { %>
    <FORM METHOD="GET" ACTION="stop.jsp">
    <INPUT TYPE="SUBMIT" VALUE="Stop">
    </FORM>
    <% } else { %>
    <FORM METHOD="GET" ACTION="start.jsp">
    <INPUT TYPE="SUBMIT" VALUE="Start">
    </FORM>
    <% } %>
    </TD>
    </TR>
    </TABLE>
    </BODY>
    </HTML>
    ////////////////////////////// stop.jsp
    <jsp:useBean id="task" scope="session"
    class="thread.TaskBean"/>
    <% task.setRunning(false); %>
    <jsp:forward page="status.jsp"/>
    deploy it into ur server and run start.jsp
    and see whatb happens

  • Authentification and Security in WebApp with JSP

    Hello to all.
    I'm developing a Web Applications with JSP's. To use the application a user must first Login.
    To restrict access via URL typing I have included in every JSP page a user_logged_in_check page that verifies that the user is logged in, and if not redirects to the Login page.
    The problem is that I must not forget to include that page in all my JSPs, and if the name of the page changes, it must be changed everywhere (though a search/replace might do the job just fine).
    I used this approach because is not server dependent (such as the Tomcat Realms example I have seen on this forum).
    Is there a better strategy?
    Is there a way to enforce security check and not rely on my attention ;)?
    Is there a pattern that solves the problem?
    Any help would be greatly appreciated.

    The first and biggest disadvantage is the repetitive coding - what happens if you realise that you need to change something - you will need to modify each of your JSP files. The chances of someone forgetting to add it in are a security risk.
    Secondly, using the web server's mechanism, in most cases, would mean that you are using a proven and much more stable security mechanism then you can whip up.
    For example, in Weblogic, you can configure a JAAS provider -- that means you are not limited to using uname/password. Your customer may have an enterprise wide single sign on policy that is supported by the JAAS provider and you can use it straight away - by just making a declarative change in the web*.xml files.
    If you must, use the Filter class (its a Servlet class, I checked after I had posted) as described in the Intercepting Filter pattern - at least thats a standard approach and will cut down on you having to rely on adding a snip of code to each of your JSPs.

  • Help with JSP Forward !!!

    I have 3 pages ...1) index.jsp 2) Forward.jsp 3) welcome.jsp
    I have 2 fields in the index.jsp once upon filling & hit submit it has to to go Forward.jsp page...in the Forward.jsp..i have coded only one tag with
    <jsp:forward page="welcome.jsp" />
    I have one question...once the page comes to Forward page...will it display the contents of the Welcome .jsp in the same page itself...or it will go to Welcome.jsp page..
    As i saw it will display the contents of Welcome.jsp page in itself...
    Please let me know...
    Regards
    Gnanesh

    I understand your question only because I have a set up totally identical to yours. The thread Matt suggested does explain the situation (i.e. the server passed control to another page but the client doesn't know that), but doesn't necessarily give a good solution a problem that you may have, and that I do have:
    If the user sees the welcome page, and for some reason decides to "reload", the forward page is re-executed, even though it has done its job. This could be a problem for session management if you specifically don't want that job being done twice in a session. Now you could hack around that, but I'd really rather see a neat solution. Is there one?

  • SQL query with JSP and WML-parameters

    Hey,
    Could you help me?
    I'm trying to do the following. WML deck card 1 send parameter to same WML deck's card help. I try to read the parameter with JSP in card help by putting the parameter to SQL query, but it doesn't work. I can read the parameter with WML in card help. I can also print the value of the parameter with JSP if I generate WML with JSP.
    /*parameter sending from card 1 to card help*/
    out.println("<go href='#helpcard'>");
    out.println("<setvar name='valittukurssi' value='$(valittukurssi)'/>");
    /*parameter read with WML in card help */
    <p>Valitse kurssi.
    $valittukurssi</p>
    /'parameter read with JSP by generating WML with JSP*/
    out.println("<p>$valittukurssi</p>");
    /* SQL query with JSP */
    ResultSet uudettulokset = uusilause.executeQuery("select * from kurssi where lyhenne='$valittukurssi'");
    Thanks,
    Rampe

    You're problem is easy to fix. You're confusing WML variables with JSP variables. See below:
    >
    /*parameter sending from card 1 to card help*/
    out.println("<go href='#helpcard'>");
    out.println("<setvar name='valittukurssi'
    value='$(valittukurssi)'/>");
    Above you set a var that will work on the phone, not in JSP.
    /*parameter read with WML in card help */
    <p>Valitse kurssi.
    $valittukurssi</p>
    Yes the above does display the parameter, because it is a client side WML var, but you cannot use this variable in the JSP code (that's why your SWL fails).
    /'parameter read with JSP by generating WML with
    JSP*/
    out.println("<p>$valittukurssi</p>");Here's you're problem, the above line is EXACTLY the same as the one before it. When the container parses through this JSP code it translates the above line to:
    <p>$valittukurssi</p> on the WML page and the CLIENT uses it's local variable to display it.
    What you need and want is to have a variable that can be used in JSP code and output to your WML page. Here's how it's done:
    out.println("<go href='#helpcard'>");
    String some_name = "valittukurssi";
    out.println("<setvar name='"+some_name+"'
    value='$("+some_name+")'/>");
    //note that you may have to escape the ( and ) with a \
    //so we displayed the variable above into the WML page, now we can use it in the SQL query:
    /* SQL query with JSP */
    ResultSet uudettulokset =
    uusilause.executeQuery("select * from kurssi where
    lyhenne='"+some_name+"'");//the end of the command is: " ' " ) ;
    Frank Krul
    Got Node?

  • Create a new directory in server with JSP

    Hi,
    How can I create a directory in server with JSP.
    File dir = new File("a");
    dir.mkdir();
    does not work. what do I do?
    best regards,

    Hi
    Check the following things.
    1. What is the path where you are creating the directory.
    2. Do you permissions to create file in that directory.
    3. do a delete on that filename if that exists just to be sure. isdeleted = filedir.delete(). Check the boolean flag isdeleted too.
    Thanx and Regards
    Aruneesh

  • Running other server-side applications with JSP

    Hi,
    I'd like to know, if is possible run with JSP (Servlet, or JavaBean) other application, which support COM. I used something like this in JavaScript:
    application=new ActiveXObject("excel.application");
    and I had all possibilities of its API. I'd like to use excel as data source for user-friendly data input.
    Thanks for all suggestions

    Hi,
    I don't realy understand your question.
    If your javascript work using activeX, this code is executed on the client side (like the excel application and the excel file).
    You can, with a JSP, generate the html page that contain the script.
    Where is the problem ?

  • Displaying an Image in an Excel Spreadsheet with JSP - URGENT

    Hi Peoples
    I can transfer the table I am using in to excel with JSP by doing:
    <%@ page contentType ="application/vnd.ms-excel" %>
    this works fine, though I have an image that sits within the table that I want to be displayed as well.
    Can this be done?? If so how???
    Thanks

    Try to insert the image into sheet from it's URL not from it's local file path
    Best regards

  • A problem in RMI with JSP..pls help

    RMI with Java is working fine,but...
    1. I am facing a problem when i use RMI with JSP..its throwing an exception during "Naming.lookup"..here is my code snippet:
    // i have stored the ServerInf and other classes in a package and i have imported it in the jsp code....object ref is getting created but lookup is throwing an exception...thoguh RMI registry is working(started)
    <%
    try {
    ServerInf ref = (ServerInf)Naming.lookup("rmi://localhost:1098/Server_bind");
    catch (Exception ex) {
    ex.printStackTrace();
    %>
    Pls tel me the cause.
    2. If i try to use RMI with Servlet and JSP, then wen the JSP runs then, it simply calls the servlet file and displayes a lonk to it instead of executing the servlet class. pls help me with this too...below is the invoking statement:
    <form method=post action='http://localhost:8080/servlet/MyRMIservlet'>
    hello <input type=submit value=submit>

    And the exception and error message is.....

  • How can I create a Login-page with jsp???

    Hello,
    I have to create a page with JSP code on the Netweaver Developer Studio.
    But I do not know how I do it.
    Can anyone tell me what to write in the portalapp.xml?
    An example would be very helpful.
    Thank you
    Greetings

    As you can see in the example:
    The portalapp.xml file (deployment descriptor) provides configuration information for your application, and defines the components and services in your application. For each component and service, you specify the implementing Java class and configuration information.
    For more information on the format of the portalapp.xml, see Deployment Descriptor (portalapp.xml).
    <application>
        <application-config>
            <property name="SharingReference" value="com.sap.portal.navigation.service, com.sap.portal.navigation.api_mimeservice, com.sap.portal.navigation.helperservice"/>
            <property name="Vendor" value="MY_COMPANY"/>
            <property name="SecurityArea" value="PERMISSION"/>
        </application-config>
        <components>
            <component name="SimpleNavigationExample">
                <component-config>
                    <property name="ClassName" value="MY_CLASS"/>
                    <property name="SecurityZone" value="no_safety"/>
                </component-config>
                <component-profile/>
            </component>
        </components>
        <services/>
    </application>
    You can only update in this example, your class name and other details:
    <property name="Vendor" value="sap.com"/>
    <property name="SecurityArea" value="MyCompany"/>
    <property name="ClassName" value="LOGINCLASS"/>
    <property name="SecurityZone" value="no_safety"/>
    Modify this portalapp.xml file as follows:
           1.      NAVIGATION SERVICE, so you must add references to the following portal applications that define these services:
            com.sap.portal.navigation.service
            com.sap.portal.navigation.api_mimeservice
            com.sap.portal.navigation.helperservice
           2.      In the <application-config> section, create the following properties that help to define the security zone for all components and services in this application:
    ○     Vendor: String identifying the company or organization that provided the application, for example, sap.com.
    ○     SecurityArea: String identifying the security area for the application, for example, NetWeaver.portal.
           3.      In the <component-config> section for the mySiteMap component, create the property SecurityZone to define the specific security zone for the component.
    For Permission, check this document:
    http://help.sap.com/saphelp_nw04s/helpdata/en/44/489e2df5ee4e35e10000000a1553f6/frameset.htm

  • Need help with XML Coding

    I'm trying to write an IF statement similar to <?if:QUANTITY='0'?> but would like to say 'is greater than' 0. I'm not very familiar with the coding in XML and what characters I'm able to use since I can't use <> in the coding. Can anyone help?
    Thanks,
    Susan

    Hello,
    If you want to represent '<' and '>' in xml you must entity encode them with &amp;lt; and &amp;gt; respectively.

  • Help me!! How to use JavaScript with JSP ??

    I am using JDeveloper and I created a screen in JSP which uses a bean for database connectivity and retriving info onto the page.
    The page has a ListBox where list items are populated from the database.My requirement is
    whenever the list is changed the page shuold be refreshed with the selected item info.
    I tried to use 'JavaScript' for triggering the event with 'onChange' event of the ListBox.But the event is not getting invoked. I think JavaScript is not working with JSP.
    Please help me with how to Use javaScript with JSP or any other alternative where I can meet my requirement.
    I have one more question...I have gone through the JSP samples in OTN and I am trying do download the sample 'Travel servlet' which show list of countries...etc
    I have also gone through the 'readme' but I don't know how to extract .jar file.
    I would be great if you could help me in this.
    Thanks!!
    Geeta
    null

    We have a similar need. We have used Cold Fusion to display data from Our Oracle Database. We have a simple SElect Box in HTML populated with the oracle data. When someone selects say the State of Pennsylvania. then we have an On change event that runs a Javascript to go get all the cities in Pennsylvania.
    Proble we are having is that inorder for the Javascript to work , we currently have to send all the valid data.
    Do you know of any way to dynamically query the the Oracle database in Javascript

  • Excel with JSP

    Hi everyone
    I relly do need some help...
    I have an Oracle Database and I need to:
    1. View my results (of any request) in an excel spreadsheet using JSP (I think this part is the easiest...)
    2. And that is my real problem: Use an excel spreadsheet to insert values in the database with JSP...
    I hope I made it clear because even for me it's really tricky...
    Thanks a lot...
    Yassi

    There is a example in Marty Hal;l's book"Core Servlets and JSP pages".
    It is static, but the same idea would work coming from a database.
    <HTML>
    <HEAD>
    <TITLE>Comparing Apples and Oranges</TITLE>
    </HEAD>
    <BODY>
    <CENTER>
    <H2>Comparing Apples and Oranges</H2>
    <%
    String format = request.getParameter("format");
    if ((format != null) && (format.equals("excel"))) {
    response.setContentType("application/vnd.ms-excel");
    %>
    <TABLE BORDER=1>
    <TR><TH></TH><TH>Apples<TH>Oranges
    <TR><TH>First Quarter<TD>2307<TD>4706
    <TR><TH>Second Quarter<TD>2982<TD>5104
    <TR><TH>Third Quarter<TD>3011<TD>5220
    <TR><TH>Fourth Quarter<TD>3055<TD>5287
    </TABLE>
    </CENTER>
    </BODY>
    </HTML>

  • Best way to deal with hard coded variables in a package

    There is a plsql package that reads a line from a file, parses the data, does a ton of sql operation with it (select update, inserts, calculations) and then writes the output to an output file.
    The file names and the firectories are retieved from a database table.
    Example:
    select location,file_name into loc_in,file_in from temp_tbl;
    p_File_handle := utl_file.fopen (loc_in, file_in, 'W');
    My co worker is suggesting that getting the variable values from the table is not a good practice. He suggests that the values should be hard-coded in the program. Now you might ask what would happen if the file name or directory changes. His suggestion is to have a build file and do a token substitution of those hard coded values in the program and then load in to the DB. In short the process will involve the following steps:
    -Get the package from the repostory.
    -Change the file name and directory in the token file.
    -Run the build process that will replace the values in the package .
    -Load the new file (with the updated values) in to the DB.
    Example:
    This way the program will be initially coded like this:
    p_File_handle := utl_file.fopen ('${loc_in}', '${file_in}', 'W');
    After the build file runs, it will replace the values as
    p_File_handle := utl_file.fopen ('C:/test', 'testfile.dat', 'W');
    Once the file has changed with the new updated values, compile that into the database.
    Ideas/comments?

    Re: Best way to deal with hard coded variables in a package: why have you reposted using a new profile?
    Neither post provides enough clear information on what the actual requirement is. We need more data in order to comment on your idea, your co-worker's, or to suggest alternatives.
    My co worker is suggesting that getting the variable
    values from the table is not a good practice.His reasons for this are...?
    "variable values": Why do they vary? How often do they change?
    The file names and the directories are retrieved from
    a database table.How do the values get into the table? What is the volume of the data?
    Oracle version? Operating system?

  • Using java bean with jsp

    hello friends,
    i'm new to jsp. i want to create an html form that accepts username and a value from four radio buttons and display back the entered name and checked radio button's value using java bean.
    i use the <jsp:setProperty id="" property="*"> method. i don't know how to access the radio buttons value from the html.
    also when i use an additional field other than username the jsp page is showing error.
    Please give me the correct method to use java bean with jsp in this circumstance.
    thank you.

    thank you, but i have a problem left. the case is like this.
    i got the jsp and bean worked fine when i have a sinle input text field.
    but when i added a second text field i recieved the following error.
    javax.servlet.ServletException: basket.newbean.getUserPass()Ljava/lang/String;
         org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
         org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
         org.apache.jsp.newform.process_jsp._jspService(process_jsp.java:69)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    where userPass is the new form element. I have made the subsequent chanes in my bean program and jsp file.
    pls hlp.

Maybe you are looking for

  • Ipod touch 3.1.3 shutdown

    Why did my ipod touch 3.1.3 shutdown & will not come back on, though it's been on charger for days.

  • Can't print emails or notes etc..

    Hi there For some reason my Canon IP4700 has decided to stop properly printing emails from my MBP (with latest mountain lion). The printer itself works ok...it prints test pages not problem. It also prints PDFs without a hitch, and photos. However wh

  • Another Adobe Air installation issue

    I've tried removing the following directories and still get an error while installing. C:\Program Files\Common Files\Adobe AIR      C:\Users\Default\AppData\Roaming\Macromedia\Flash Player\www.macromedia.com      C:\Users\phil\AppData\Roaming\Macrome

  • Paid for something, don't have any feature access, though.

    I remember paying for something when I created my Adobe ID. Fast forward to now and I need to combine multiple files into a single PDF, but Adobe is prompting me to pay for a PDF pack that is about the same price as what I remember having already pai

  • What does the table save business system informations?

    Hi... When we create or change the business system in SLD, What table does the information about business system save in the database? Thank you..