How to include a jsp file in servlets and javabeans

Hi to all..I have a jsp file which contains some database connections and I would like to include in that file in my servlets and javabeans.What coding can i use?Can show me sample coding.

Hi to all..I have created a javabean storing the
database connections. How do i include and call that
bean in my servlet and javabeans?Can pls show me some
sample coding?I am new to servlets and beans.The same way you do with normal Java Classes. If you are new to Java, I suggest you go to http://java.sun.com/docs/books/tutorial/index.html and look through the first couple of tutorials.
As a note, it is best to put all your objects into packages, especially if you use JDK 1.4 or higher.

Similar Messages

  • How can i include a jsp file in servlet?

    hi
    i generate a dynamic page from servlet.
    i need to include a jsp file in same servlet.
    i try like this --
    out.println("<HTML>");
    out.println("<HEAD><TITLE>First</TITLE></HEAD>");
    out.println("<BODY>");
    out.println("<%@ include file=\"abc.jsp\">");
    out.println("<FORM>");
    out.println("</FORM>");
    out.println("</BODY>");
    out.println("</HTML>");

    Replace your line with
    RequestDispatcher rd = request.getRequestDispatcher("abc.jsp");
    rd.include(request, response);

  • How to include a jsp file from other site

    Hi all,
    I met a problem in my recent work. I need to include another seperate jsp file into my current jsp file, but the file is located at the different site (different physical server). Is there a way to include?
    Cheers
    Chris

    Thanks tolmank, but our weblogic server didn't support jstl, so when I try to using <c:import.. > it doesn't work. If I use <jsp:include page="..."/>, nothing display on the page.

  • How to deploy custom JSP file in reporting and analysis workspace extented services?

    Hi All,
    We are using Oracle EPM 11.2.3 Interactive reporting.  We need add on functionality on the existing workspace and developed a JAVA code for that. Now we are facing challenges with deploying JSP file with existing weblogic server. does anybody did it before? we followed oracle doc but not useful.
    The task of JSP file would get the user information from the existing session then list the file which user has access and follow.
    Do we have any doc related to this? Your help is highly appreciated.
    Thanks
    Venkatesh

    Hi,
    After deployed inside the OC4J server. Run the index page by
    Calling like http://hostname:port/earname/index.jsp
    While deploying the ear file you would have given a name for the ear file use that name in the URL.
    If so then you can see the provider displayed on the index page. Then click on the provider name it will take you to the next page where it will display all the portlet inside the provider.
    Please copy the URL and paste it while registering the Provider with the portal server.
    Because the server will try to navigate to the URL mentioned while registering if the server dint find the proper URL then registration fails.
    Try this and let me know.
    Regards,
    Vijay.B

  • How to include External .JS File in .aspx and .ascx page???

    This is my Code::
    .aspx Code:::
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Calculator_Using_UserControl_And_Js.aspx.cs" Inherits="Calculator_Using_UserControl_And_Js" %>
    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
     <title></title>
      <script src="/JS/JavaScript.js" type="text/javascript"></script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div align="center"> 
            <p style="color:brown">Welcome to User Control Page</p> 
            A:<asp:TextBox ID="tbA" runat="server"></asp:TextBox>
            B:<asp:TextBox ID="tbB" runat="server"></asp:TextBox>
            <asp:Button ID="btnAdd" runat="server" Text="ADD" OnClientClick="return fnAdd()"/>
            <asp:Button ID="btnSub" runat="server" Text="SUB" OnClientClick="return fnSub()" />
        </div>
        </form>
    </body>
    </html>
    .JS code
    function fnAdd() {
        var v1 = document.getElementById(tbA).value;
        var v2 = document.getElementById(tbB).value;
        var res = parseInt(v1) + parseInt(v2);
        alert(res);
        return false;
    function fnSub() 
        var A = document.getElementById(tbA).value;
        var B = document.getElementById(tbB).value;
        var res = parseInt(A) - parseInt(B);
        alert(res);
        return false;
    I 've tried with the following methods but no use...
    <script type="text/javascript" src="<%= ResolveUrl ("~/Scripts/MyScriptFile.js") %>"></script>
    <script type="text/javascript" src="../JScript.js"></script>
    <script src="javascript.js" ></script>
    Thanks & Regards RAJENDRAN M

    You can write JS function as follows:
    function fnAdd(numberA,numberB,totalT) {
    var v1 = document.getElementById(numberA).value;
    var v2 = document.getElementById(numberB).value;
    var total = parseInt(v1) + parseInt(v2);
    document.getElementById(totalT).value = total;
    return false;
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <title></title>
    <script src="javascript.js"></script>
    </head>
    <body>
    <form id="form1" runat="server">
    <div>
    A: <asp:TextBox ID="numberA" runat="server"></asp:TextBox><br />
    B: <asp:TextBox ID="numberB" runat="server"></asp:TextBox><br />
    T: <asp:TextBox ID="totalT" runat="server"></asp:TextBox><br />
    <asp:Button ID="btnAdd" runat="server" Text="Add" OnClientClick="return fnAdd('numberA','numberB','totalT');" />
    </div>
    </form>
    </body>
    </html>
    And you can do the same for fnSub

  • How can i upload files in servlets and also using jsp

    means that uploading files(.doc) or any files by using servlets and jsps

    yawmark wrote:
    saichand wrote:
    means that uploading files(.doc) or any files by using servlets and jsps
    [http://www.google.com/search?q=How+can+i+upload+files+in+servlets+and+also+using+jsp]
    ~Good topic titles are indeed brilliant search keywords. It's sad to see that it won't even come in the mind of the topicstarters to Google it before posting the topic.

  • Include directive to include a JSP file from a JAR file

    I have an Eclipse project in which I have placed a JSP file in the package structure with the rest of my code. This is in fact only a code snippet page, not a full blown JSP file.
    I have a second project that is a Dynamic Web Project in Eclipse that incorporates the first project as a JAR in the /WEB-INF/lib directory.
    In this project I have a JSP file and I want to include the JSP file embedded in that JAR file.
    How do I do that?
    I'm thinking the only real solution is to rewrite the snippet portion as a custom tag.

    The JSP fragment page in question is actually a HTML form page. It is a form to be used specifically by a particular servlet. That is why they are "bundled" together in the same project, in the same package structure.
    I have multiple web applications that I want to include that form/servlet, so it gets added to these projects in the /WEB-INF/lib folder as a JAR library. But I don't want to recreate the form over and over again for each application. It would be nice if I could write a JSP page that wraps the fragment using an include directive to bring that fragment into the new page.
    So to do that with any other fragment I would write:
    <%@ include file="/WEB-INF/jsp/SOME_FORM.jsp" %>
    which works great if my fragment page is in the /WEB-INF/jsp subfolder. But if I want to access the JSP fragment as it is bundled in a JAR file, this:
    <%@ include file="/WEB-INF/lib/FORM.jar/SOME_FORM.jsp" %>
    doesn't work so good. It's just all wrong.
    I was wondering how I could just write one include statement to get what I need. There are work-arounds galore, but I thought if I could get this working it would be the simplest solution overall.

  • How to add existing jsp file to a project?

    I am trying out 10g developer preview. Looks like a lot of bugs are there in the tool. I would like to know how to add existing jsp file into a project. I tried the Import functionality, but it shows the option to create a project and include only Java files. Is there a way to do this? Thank you

    Just copy the files in the directory where the rest of your source file is.

  • How to include a dynamic file

    Hi,
    The following syntax does not work:
    <%@ include file="htmls/mydocs/<%=dynamicFileName%>.htm" %>
    could you tell me how to include a dynamic file?
    thanks,
    peterzhu

    The include directive <%@ include ... does not work with dynamic file names, because it is evaluated at compile time.
    You have to use the include standard action <jsp:include page=... This is executed during runtime, and hence a dynamic file name can be used.

  • Include a JSP file located in a JAR

    how is it possible to include a jsp file which is located in a jar? perhaps someone has already a solution for this hoping
    what I already have found out is that jasper parser supports loading JSP files out of JARs, indeed. but when using a <%@import file="foo.jsp"%> directive, this special method is not called. is there some workaround? should I set some special property?
    thx

    Did you ever figure this one out?

  • How to deploy a jsp file?

    Hello,
    I am new to Java. I have been developing a small web application which contains three files HTML,SERVLET and a JSP. I don't have any problem with the html & Servlet, It runs well and I get the desired output.
    I use the JSP file for validation.
    But, How to run this JSP?
    i.e. I want to run this JSP page from Servlet while performing some validations.
    Plz let me know
    where should I put this JSP? (I am using Tomcat server)
    Is there any need to enter data into web.xml similar to Servlet?
    Is there any need to set some environmental variables etc etc...
    Hope a quick respone.
    Thank you.

    This is my servlet code........
    import java.sql.*;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class ServerConfig extends HttpServlet
    Connection con;
    Statement st;
    ResultSet rs;
    public void init(ServletConfig config) throws ServletException
         super.init(config);
         try
         Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
         con=DriverManager.getConnection("jdbc:odbc:ServerConfig"," "," ");
         st=con.createStatement();
         }catch(Exception se){System.out.println("problem with connection establishment");}
    public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
         String s1,s2,s3,s4;
         res.setContentType("text/html");
         PrintWriter out = res.getWriter();
         int branches = Integer.parseInt(req.getParameter("txtBranches"));
         int users = Integer.parseInt(req.getParameter("txtUsers"));
         int accounts = Integer.parseInt(req.getParameter("txtAccounts"));
         int transactions = Integer.parseInt(req.getParameter("txtTransactions"));
         out.println("<HTML>");
         out.println("<HEAD><TITLE>Server Configuraion</TITLE></HEAD>");
         out.println("<BODY>");
         out.println("<B>Best Server Configuraion</B><HR>");
         out.println("<FORM>");
         out.println("Branches: " + branches);
         out.println("<BR>");
         out.println("Users: "+ users);
         out.println("<BR>");
         out.println("Accounts: "+ accounts);
         out.println("<BR>");
         out.println("Transactions: "+ transactions);
         out.println("<HR>");
         try
         Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
         System.out.println("DriverLoaded");
         Connection con=DriverManager.getConnection("jdbc:odbc:ServerConfig"," "," ");
         System.out.println("Connected");
         Statement st=con.createStatement();
         ResultSet rs=st.executeQuery("select DatabaseConfig,ApplicationConfig,WebConfig,BranchConfig from Configuration                     where Branches="+ branches +" and Transactions="+ transactions +" and                                         Accounts="+ accounts +" and Users="+ users +";");
         rs.next();
         s1 = rs.getString(1);
         s2 = rs.getString(2);
         s3 = rs.getString(3);
         s4 = rs.getString(4);
         if (s1.length()==0)||(s2.length()==0)||(s3.length()==0)
    //Plz let me know how should I call JSP?????
    out.println("Database Server:<BR>    <textarea rows=5 cols=30>"+s1+"</textarea><BR>");
         out.println("Application Server:<BR>    <textarea rows=5 cols=30>"+s2+"</textarea><BR>");
         out.println("Branch Server:<BR>    <textarea rows=5 cols=30>"+s3+"</textarea><BR>");
         out.println("Web Server:<BR>    <textarea rows=5 cols=30>"+s4+"</textarea><BR>");
         out.println("</FORM>");
         out.println("</BODY>");
         out.println("</HTML>");
         con.close();
         }catch(Exception ex){System.out.println(ex);ex.printStackTrace();}
    };

  • How to call a .jsp file from Applet

    Could any one guide me how to call a .jsp file from a Applet using action Event.
    Thanks

    http://javaalmanac.com/cgi-bin/search/find.pl?words=URL+post

  • How to send a JSP file in a MAU patch

    Hi friends,
    We need to send a patch for enhancement, which contains classes and a JSP file also.  So, we know how to send class files, but we are not aware of how to send a JSP file in the patch.
    Please help us if anybody know this.
    Thanks & Regards,
    Ravi

    Hi Ravi,
    <b>Is is possible to update this jar file or to change some mappings?</b>--->I think you can not update the application.jar file.
    Let me know one thing, while you creating war file from NWDS/Eclipse did you compile JSP pages as Precompiled class files. If you did that, your application will not point JSP pages that you applied as patches.
    Is your application is in production phase? If yes, my first suggestion is..If you have updated application.jar file, apply the application.jar file as patch.
    If your application is not in production phase....best option is, again create a war file as pre-compiled jsp pages, and make changes in NWDS that the compiled class files should loaded as application.jar file. Then you can apply patches easily.
    Hope this helps you..
    Regards,
    Murthy

  • How to include assigned .as files in MXMLC ant task ?

    When i use mxmlc ant task, i found that
    the tag <include-sources/> doesn't support !
    ( described by http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7a63.html )
    neither SDK version 3.x nor 4.x
    Are they lying?!
    How to include assigned .as files ?
    Thank you !

    My understanding is that mxmlc will use all available resources in the source path, as needed. Instead of giving it individual resources to include, you simply need to give it the source-path that contains those resources. This is different from a library project, which may need to include individual classes that are never used in that library.

  • ANT how to include NetBeans Jar  files in my script of ANT ??

    ANT how to include NetBeans Jar files in my script of ANT ??

    I mean the library say swing layout ...
    which is SwingLayOuts1.0.jar ...
    in side this there is folder org.jDesktop....
    I want this folder in my jar file ...
    also ....
    My question ... i know the path of the jar file of NetBeans .... i can copy that ...dirctly ... but if m using Netbeans editor ... can i give NetBeans class to my jar command for ANT...........

Maybe you are looking for