Hi @include in a JSP function

Hi,
I wanted to use the @include directive in a jsp function. But when I compile it I get errors.
Is this allowed ?
<%!
private boolean isDisplayAllowed () {
%>
<%@include file="foo.inc"%>
<%@include file="bar.inc"%>
<%
%>
Thanks
RT

Thanks
I have a code that is needed to be shared between multiple jsp files. So I moved them to an inc, file so as to share between multiple files.
Now I need to use this in jsp functions, so I am not sure how to do this.
If instead of using include approach if there is any other way to share the code, please let me know.
Thanks
RT

Similar Messages

  • How to use session variable in JSP function  & How to use both JSP  Servlet

    Hi,
    I am new to JSP and servlets
    Still I am devloping a website in JSP. I am not mixing JSP with servlets, but I do create Java files for bean, logic and database works.
    I try to keep the hard coding part out of JSP.
    I dont how to use both JSP and Servlets in combination.
    Hence If needed I write some functions in JSP.
    but it gives me error
    +<%! public void abc()+
    +{+
    int intUserId = Integer.valueOf((Integer) session.getAttribute("MySession_UserID"));
    +}+
    +%>+
    Saying cannot find symbol session
    1) So can u please tell how can I access session variables within JSP function
    2) And also give me some links/tutorials about useing both JSP and Servlets in combination.
    Thanks
    Venkat

    The application architecture when you use Servlets and JSP in a standard MVC pattern is explained here (under the heading "Integrating Servlets and JSP Pages") and here ...

  • Dynamic include file in JSP page

    <span class="value">Hi
    i have index.jsp , this page can include jsp
    pages dynamically by passing the name of the page to be included to the
    index page with out .jsp , so if i want to include page "code.jsp" i
    put: .../index.jsp?page=code , this have to include code.jsp page
    i made the following code , but it did not find the file
    so can any one help plz ?
            String pg=request.getParameter("page");
            if( pg!= null && ! "".equals(pg)){
                    File f=new File(request.getParameter("page")+".jsp");
                    if(f.exists()){
                            out.print("file exist");
                            %>
                            <jsp:include page="<%=request.getParameter("page")+".jsp" %>" />
            <%
                    }else{
                            out.print("file not exist");
         

    What does the file existing or not really have to do with it?
    You can try it like this:
    String pg=request.getParameter("page");
            if( pg!= null && ! "".equals(pg)){
                    String webPath = pg + " .jsp";
                    String realPath = request.getRealPath(webPath);
                    File f=new File(realPath);
                    if(f.exists()){
                            out.print("file exist");
                            %>
                            <jsp:include page="<%= webPath %>" />
            <%
                    }else{
                            out.print("file not exist");
            }Alternatively you could try using a request dispatcher:
    RequestDispatcher rd = request.getRequestDispatcher(webPath);
    if (rd == null){
      // doesn't exist
    }

  • How to use sswa jsp function in personalization?

    I have a question. When I add a custom item of type link in a region using personalization, how can i access the click of the link as an event in that region';s controller.
    Also if I want to use the "destination function" field of the new Link created with an existing seeded SSWA JSP function, how do i pass url parameter values to this function.
    The function name is IMC_NG_PER_SOURCE_VIEW and the HTML call is OA.jsp?page=/oracle/apps/imc/ocong/mosr/webui/ImcPerMosrViewPage&ImcPartyId={@ImcPartyId}&ImcPartyName={@ImcPartyName}&ImcMainPartyId={@ImcMainPartyId}
    Now when I click the link on the Page the HTML call is made as is, i.e. the target Page ImcPerMosrViewPage gets the value for ImcPartyId = "{@ImcPartyId}" instead of the real Party ID.
    Whereas on the same Page there is a side bar Menu, and one of the Menu item makes a call to the same sswa jsp function and when we click the menu item the target page is rendered successfully.
    So my question is how do I make the link on the region to work the same way as the Menu item.
    It would be great of you could share some tips to resolve this issue of mine.
    Many Thanks!
    Jay

    Just set the fire Action property of that link and capture that in controller PFR.
    Thanks
    --Anil                                                                                                                                                                                                           

  • Calling out.println in a jsp function

    Hi, i want to call out.println in a jsp function. That is i am using function like this
    <%!
    void MyFunction()
    out.println("this is good");
    %>
    This code fails with error message: "out cannot be resolved"
    Also i don't want to return value from the function, since i will later call this function recursive and display value at each instant.
    Please suggest any solution.

    <%!
    void MyFunction(JSPWriter out)
    out.println("this is good");
    %>and then execute it with:
    <% MyFunction(out): %>

  • Include file in jsp not working

    Hi ,
    I have an include file statement in my jsp file which is not working. Not getting any error message either only the page is displayed without the jsp file included.
    My include code looks like this :
    <%@ include file ="Includes/hello.jsp" %>Also i tried including an html file or an image in the same place neither of the two displayed.
    <!--#include virtual="includes/footer.html" -->
    My jsp file is hosted on IIS

    nb123 wrote:My jsp file is hosted on IIS
    Hi ,
    I have an include file statement in my jsp file which is not working. Not getting any error message either only the page is displayed without the jsp file included.
    My include code looks like this :
    <%@ include file ="Includes/hello.jsp" %>Also i tried including an html file or an image in the same place neither of the two displayed.
    <!--#include virtual="includes/footer.html" -->
    My jsp file is hosted on IIS
    Check the path you've specified. It may well be;
    <%@include file="hello.jsp" %>or
    <%@include file="/Includes/hello.jsp" %>

  • How to call JSP function from onClick Action

    Hi
    I am trying to call a jsp function, onclick of a checkbox. This jsp function will in turn connect to the database and gets related information. I dont want to submit the data inorder to avoid posting and getting of huge data. Is there a simple way to call a jsp function from the users onClick action.
    Appreciate anyones help!!!
    Thanks alot
    Joe

    So, i have to submit the form to call the jsp function. Basically yes.
    Sorry for the shortness of the answer, but I am pretty sure we have had this conversation (or one very much like it) before.
    Java/JSP runs on the server, generates an html page, and stops running.
    Javascript runs on the client in the web browser, once the page is loaded.
    You cannot call java code from javascript.
    The only way you can run java code again is to make a request - either by submitting a form, or clicking a link.
    If you don't want to refresh the current page, you CAN get tricky with javascript and multiple frames. You submit to another frame, and when it loads, it uses javascript onload event to call back and modify the main frame. Its tricky to get going, and very easy to break, so I don't normally recommend it.
    Good luck,
    evnafets

  • Include a page .jsp

    It is possible to include a page .jsp in another page???
    How??
    thanks

    Perhaps you mean a page fragment (jspf)?
    If so, see http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/pagefragments.html

  • Sun Studio cc includes unused static inline functions in object file

    While trying to compile some code originally compiled with GCC I run into a linking problem. My problem seems to be caused by that GCC does not include unused static inline functions in the object files while cc does. The following simple example can be used for illustrating this:
    void foo();
    static inline void bar()
      foo();
    int main()
    }This program compiles and links without any problems using GCC and Sun Studio 12 CC (the C++ compiler) but fails to link using Sun Studio 12 cc:
    khepri%> cc staticinline.c
    Undefined first referenced
    symbol in file
    foo staticinline.o
    ld: fatal: Symbol referencing errors. No output written to a.out
    It is probably fine of cc to include foo() in the object file (although not necessary?). My questions are:
    1. Are there any reasons for why cc includes unused static inline functions in the object file while CC does not?
    2. Are there any ways or options to tell cc to not include unused static inline functions in the object file?
    In the example above this is easy to fix by just removing or #ifdef away the code but the original code where I have this problem is not maintained by me and the static inline functions are in header files that get included in multiple C files and in some of these the functions are used.
    Thanks,
    Olav

    olavsa wrote:
    1. Are there any reasons for why cc includes unused static inline functions in the object file while CC does not?
    2. Are there any ways or options to tell cc to not include unused static inline functions in the object file?Removing dead code is an optimization, so you need at least -xO1 for that.

  • Couldn't include CNTN01 in z function group created at SE80

    Dear All,
             I am involved in workflow development for determining agent for a step.
             But I couldn't include <CNTN01> in z function group created at SE80?
             How to do so?I will be grateful for your help.
    Thanks,
    S.Suresh

    Hi Samson,
                   Thanks for your reply.
                   As you stated, <CNTN01> is found at the include file LSWEATOP under the function group SWEA.
                   It implies that I need not include ,<CNTN01> in my z function group?
    Thanks,
    S.Suresh

  • Error when using %@ include file="/test.jsp"%&

    UsingNitrox version 2.1 M3 (build 419 06022005):
    with jdk version: 1.5.0_03 and Tomcat 5.5.9
    This is the error :cry: when using <%@ include file="/test.jsp"%> in jsp:
    Severity     2
    The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files (test.jsp)
    It used to work in previuos version of Nitrox. I can't use struts tiles because the tiles content is dynamic (run time) and I need it to be static (at compile time).
    Have you encountered this problem? What is the fix? Nitrox bug?
    I need your help please,
    Alberto

    M7,
    I found the problem :wink: . In the java Build path having the default (ALL) is not picking up the content of the package. I had to use add multiple and include all the folders and subfolders (many L) in my packages. After that I added *.java and *.properties to select all the java files. Now it is working. I assume this is a bug in Nitrox. The default ALL should include the all the files in the path.
    Thanks,
    Alberto

  • "include directive or jsp:include "

    Hi,
    Which amongst <%@ include file="header.jsp" %> and
    <jsp:include page="header.jsp"/>to be used, when performance is taken into account.

    Code copy from serverside.com
    Is it the same as --> jsp:include and %@ include directive.
    Actually, <jsp:include> vs. <%@ include %> is a different story.
    <%@ include %> is a "compile-time" include. The included file is inserted into the JSP when the JSP compiles.
    <jsp:include> is a "run-time" include. If JSP-1 includes JSP-2, JSP-2 is invoked when JSP-1 executes, and the output of JSP-2 is inserted into the output stream of JSP-1.
    The run-time include runs a bit slowly, but can save a lot of system memory, so in general, the run-time include is preferable. Only use the compile-time include if the include code must be in the same page.
    For example, if you want to use an include that defines a bunch of tag libraries with the taglib directive, it will have to be a compile-time include. If you just want to insert a standard header and footer in your page, a run-time include will be more effecient.
    I hope its enough for you to get an clear cut idea,

  • Pls tell me use %@ include file="myfile.jsp"% with endcoding UTF-8??

    My jsp pages use some endcoding as UTF-8.
              When I use <%@ include file="myfile.jsp"%> endcoding lose format UTF-8. But
              if I use <jsp:forward page="myfile.jsp"/> it work fine.
              Pls tell me use <%@include %>
              (I use Jbuilder 6 and weblogic server 6.1)
              Thanks .
              

    From http://java.sun.com/products/jsp/tags/12/syntaxref1214.html#8828 (emphasis mine):
    page="{ relativeURL | <%= expression %> }"
    The relative URL that locates the resource to be included, or an expression that evaluates to a String equivalent to the relative URL.
    The relative URL looks like a pathname--it cannot contain a protocol name, port number, or domain name. The URL can be absolute or relative to the current JSP page. If it is absolute (beginning with a /), the pathname is resolved by your web or application server.
    You could use a servlet in your "path" attribute and have that servlet read and return the page from a different server; there are ways to do what you want, but <jsp:include> isn't one of them.

  • Problems with include where the include is a jsp

    Hi ,
    I have a typical problem. The iplanet server doesn't interpret the code
    from a jsp which is included in another jsp. For eg.
    code for main jsp
    request.getParameter("username");
    <%@ include file="/jsp/ui/left_nav.jsp" %>
    processing code.
    Now when I start the server and the first time I load this page I get a
    dearranged page which has the code of the left_nav.jsp present in the html
    output.
    On opening this page to edit, when a small modification is made and the file
    is saved, a reload of the same page gives the proper output with all the
    jsp's interpreted.
    Thanks to one and all,
    Regards,
    Gurjit

    You definitely want to use a jsp include action, not a directive. The directive
    happens at translation time and does not process the requested page. An action
    happens at request time and treats the requested page as a new request, thus
    including the results of the invoked jsp.
    BTW, the include action is the tags that looks line <jsp:inculde
    page="included_page.jsp" flush="true"/> or something similar (parameters can
    also be specified).
    The JSP 1.1 spec has more details. See sections 2.7.5 & 2.7.6 (for the include
    directive and a quick comparison of the directive vs the action) and 2.13.4 (for
    the include action).
    Matt
    Gurjit wrote:
    Hi ,
    I have a typical problem. The iplanet server doesn't interpret the code
    from a jsp which is included in another jsp. For eg.
    code for main jsp
    request.getParameter("username");
    <%@ include file="/jsp/ui/left_nav.jsp" %>
    processing code.
    Now when I start the server and the first time I load this page I get a
    dearranged page which has the code of the left_nav.jsp present in the html
    output.
    On opening this page to edit, when a small modification is made and the file
    is saved, a reload of the same page gives the proper output with all the
    jsp's interpreted.
    Thanks to one and all,
    Regards,
    Gurjit

  • Call jsp function in javascript without using Applet

    anyone knows how to call jsp function in javascript .
    just as follows:
    <%!
    public string jspcall()
    return new String("just a example");
    %>
    <script language="javascript">
    <!--
    temp = jspcall();
    //->
    </script>
    it's desn't work.
    any suggestion will help!

    it's was not able to call a jsp function in javascript.
    jsp function was on server site while javascript normally on the client site.

Maybe you are looking for

  • SAV for Mac 9.2.7 released!

    Hey everyone, We released SAV for Mac 9.2.7 to all home users late last week.  This release at a glance: Compatible with OSX 10.6 - 10.10 Stability and performance improvements Updated threat engine and threat data (release notes for threat detection

  • Upgrading from 10.3 to 10.4 on a iBook G3

    My friend has an iBook G3 and needs to upgrade for the iPhone. I was going over some of the tech specs and became concerned whether the iBook G3 could handle the upgrade-- I mean whether it would meet all the requirements or whether it is even worth

  • Suspends only every second time when lid closed

    Hello everybody, my problem is as the  subject: to suspend I have to close usually the laptop lid twice. I'm using kde, but I have also used years ago fluxbox, tweaking scripts and using laptop-mode (which is not running now). Thanks in advance for e

  • Schema qname collision issue

    I am trying to apply a BPEL orchestration (11g PS2) to receive and process an outbound msg from Salesforce. Salesforce provides the wsdl for the outbound msg that Salesforce sends to my service. Alone, this is not a problem. However, circumstances re

  • Third Party Scheduling

    Greetings, working at a customer site who is interested in using a third party tool Control-M to schedule the execution of business objects reports. What kind of integration is required to accomodate this request? M