Include ".txt" as if it was a ".jsp" in servlet

Hi,
I am able to include a ".jsp" file from a servlet, but is it possible to include a ".txt" file but "render" it as if it was a ".jsp" (if the .txt file contains jstl tags, for example, I want the code to be "rendered" and not just outputed like normal text)
Thanks

Hi there,
It's important to remember that there are two basic ways to make the
front panel of a SubVI appear when the SubVI is called from another VI.
Only the first method has been mentioned in this thread:
1. In case you have a SubVI that you always want to open as a dialog when it's called from any other VI, go to the "File » VI Properties..." menu and customize the "Window Appearance" to "Show front panel when called" and "Close afterwards if originally closed". After applying these settings, the front panel of the SubVI will pop up every time the SubVI is called within another VI.
2. If you only want a SubVI to pop up in some places where it is
called, you should not customize the actual SubVI, but instead
customize the call to the SubVI. Do this by right-clicking on the icon
of the SubVI on the block diagram of the main VI. Select "SubVI Node Setup..." and enable "Show Front Panel when called" and "Close afterwards if originally closed". After this, the SubVI will only pop up in the actual call.
To run the SubVI only when a button is pressed, use a Case Structure or
an Event Structure. Here's a small example that shows these two methods:
Have fun!
Message Edited by Philip C. on 07-20-2005 09:13 PM
- Philip Courtois, Thinkbot Solutions
Attachments:
CallSub.PNG ‏22 KB
CallSubExample.zip ‏21 KB

Similar Messages

  • I installed the new version of iTunes today. It's 12.1.1. After completing the installation, including restarting my computer, I was no longer able to use Windows Internet Explorer. Has anybody else experienced this? If so, how did you fix Explorer?

    I installed the new version of iTunes today. It's 12.1.1. After completing the installation, including restarting my computer, I was no longer able to use Windows Internet Explorer. Has anybody else experienced this? If so, how did you fix Explorer? I was using Explorer 11 and Windows 7, installed on an HP Pavilion g series

    Never heard of that being caused by installing iTunes. Try asking on a Windows forum. This isn't a problem with iTunes or any other Apple product. If you believe it is, uninstall iTunes. If the problem persists, you'll have to seek advice on a Windows forum or contact Microsoft for support.

  • In jsp:includes , is there a flush="false" in jsp 1.1

              In <jsp:includes>, is there a flush="false" in jsp 1.1...i know that it's going
              to be in jsp 1.2 but is there something like it that i can use in jsp 1.1.
              

    As far as I know (not very far, btw) new versions of Java are now only distributed from Oracle specifically for OS X. Apple is no longer updating Java beyond the version distributed with the 2014-001 security update. Java SE Runtime Environment 7 1.7.0_67 is the most recent Oracle release. That's pretty much all I know.

  • Ipad mini charger explode , why apple authorize service center said that physical damage were not included in warranty.. it was product failure !!

    Ipad mini charger explode , why apple authorize service center said that physical damage were not included in warranty.. it was product failure !!

    You will have to speak to Apple regaring this issue. No one here can do any more for you than suggest you contact Apple.

  • Thunderbird 31.3.0 pops an error message saying I Forgot to include an attachment, when it was supposed to go without it.

    Hi
    Every time I send a message Thunderbird v 31.3.0 (latest) keeps popping up a message saying I Forgot to include an attachment, when it was supposed to go without it. (there is no mention to attachments in the message body or subject)
    Can anyone help?
    Regards
    Carlos

    Thank you King_Penguin!  It worked beautifully.  I had turned the firewalls off but not the antivirus.  You are great!  I am new to this apple community thing so it looks like I cannot mark your reply as "correct answers", but it was.  Thanks a ton!

  • Deploying a WAR file containing .jsp and servlets (also uses JNI)

    Deploying a WAR file containing .jsp and servlets (also uses JNI) on Windows 2000
    We had problems making it initially work on Sun ONE Web Server 6.0 Service Pack 1 because of lack of good iPlanet Web
    Server documentation on deploying such files.
    This is how we went about it:
    1) Make one of the servlet and JSP (must call another Java Class) web application (.war) examples work with iPlanet Web
    Server.
    C:\iPlanet\Servers\plugins\servlets\examples\web-apps\HelloWorld\HelloWorld.war
    and
    C:\iPlanet\Servers\plugins\servlets\examples\web-apps\jakarta-examples\jarkarta-examples.war
    a) Go to your Web Server Administration to deploy the application using GUI Web Application Deploy.
    (We usually use command line, we experienced some issues with the GUI version, but maybe it is fixed in the new Web Server
    service packs)
    From browser, open http://yourserver:8888/
    Click on Select a Server:Manage
    Click on Virtual Server Class
    Click on https-yourserver
    Click on the Web Applications Tab
    Then, click on Deploy Web Application
    Enter the following -
    WAR File On: Local
    WAR File Path: C:\iPlanet\Servers\plugins\servlets\examples\web-apps\jakarta-examples\jarkarta-examples.war
    Application URI: /jakarta
    Installation Directory: c:\iPlanet\examples\jakarta-examples
    By clicking on OK it deployed the application.
    I can verify that it is deployed by selecting "Edit Web Applications" and I see the following entry:
    Edit     /jakarta     c:/iPlanet/examples/jakarta-examples
    Also, c:/iPlanet/examples/jakarta-examples should have the similar following directory structure ..
    - [images]
    - [jsp]
    - index.html
    - [servlets]
    - [META-INF]
    - [WEB-INF]
    - [classes]
    - [tlds]
    - web.xml
    - index.html
    I restarted the server and accessed it using the following URL from my IE browser:
    http://yourserver/jakarta/index.html
    Then I clicked on the JSP Examples and tried some JSP examples.
    b) Alternatively, you can also deploy the same example from the command-line.
    Make sure C:\iPlanet\Servers\bin\https\httpadmin\bin\ is in your path
    wdeploy deploy      -u /jakarta
              -i yourserver
              -v https-yourserver
              -d c:\iplanet\examples\jakarta-examples
              C:\iPlanet\Servers\plugins\servlets\examples\web-apps\jakarta-examples\jarkarta-examples.war
    Restart the web server (I don't think you have to restart, but .. might as well).
    2)Deploy your web-application
    My Foo.war has the following structure.
    You can use jar tf Foo.war to look at the file contents from command line (assuming you have JDK installed and the bin is
    in your PATH)
    Foo.war
    - [META-INF]
    - [WEB-INF]
    - web.xml
    - [classes]
    - Bar.class
    - MoServlet.class
    - [lib]
    - ThirdParty.jar
    - [natlib]
    - extlib.dll
    - foo.jsp
    Here is our application scenario:
    foo.jsp uses a class call Bar (it is not in any package). The Bar java class uses classes from ThirdParty.jar. The
    ThirdParty.jar in turn uses JNI to load library extlib.dll. foo.jsp also calls /servlet/Mo as well.
    Now to deploy it, do the following:
    (a) Make sure that within foo.jsp, you import the Bar class ( I don't know why you have to do it, but if you don't you get
    JSP compile error).
    <%@page language="java" import="Bar" contentType="text/html"%>
    (b) Check web.xml (for Servlets)
    Within web.xml, make sure you have the following mappings:
    <servlet>
    <servlet-name> MoLink </servlet-name>
    <servlet-class> MoServlet </servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name> MoLink </servlet-name>
    <url-pattern> /servlet/Mo </url-pattern>
    </servlet-mapping>
    (c) Deploy the application
    Using command line:
    wdeploy deploy      -u /foo
              -i yourserver
              -v https-yourserver
              -d c:\iplanet\examples\foo-dir
              Foo.war
    (d) Change web-apps.xml file (for picking up ThirdParty.jar)
    It is located in
    C:\iPlanet\Servers\https-yourserver\config
    You should see something similar to following after successful deployment.
    <web-app uri="/foo" dir="C:\iPlanet\examples\foo-dir" enable="true"/>
    Change it to look like following to pick up the ThirdParty.jar
    <web-app uri="/foo" dir="C:\iPlanet\examples\foo-dir" enable="true">
    <class-loader reload-interval="300"
              classpath="C:/iPlanet/examples/foo-dir/WEB-INF/lib/ThirdParty.jar"
              delegate="false"/>
    </web-app>
    (e) Change jvm12.conf file (for JNI)
    It is located in
    C:\iPlanet\Servers\https-yourserver\config
    Add or uncomment the following lines:
    #optional - just helps with instrumenting the jsp and servlet code
    jvm.include.CLASSPATH=1
    jvm.enableDebug=1
    nes.jsp.enabledebug=1
    jvm.trace=7
    jvm.verboseMode=1
    #required for JNI
    java.compiler=NONE
    jvm.classpath=.;C:\JDK1.3.1\lib\tools.jar;C:/iPlanet/Servers/plugins/servlets/examples/legacy/beans.10/SDKBeans10.jar;
    jvm.option=-Xrs
    jvm.option=-Xnoagent
    # not sure if this is needed for iPlanet web server
    jvm.option=-Djava.library.path=C:/iPlanet/examples/foo-dir/natlib/ -Djava.compiler=NONE
    (f) Change magnus.conf file (for JNI)
    We HAD to change this file in order for ThirdParty.jar file to pick up the native C++ code using JNI. Apparently, the
    iPlanet Web Server doesn't pick the Environment Variable Path. Because when we had the directory containing the DLL just
    in Path, it didn't work.
    Change Extrapath directive:
    ExtraPath C:/iPlanet/Servers/bin/https/bin;${NSES_JRE_RUNTIME_LIBPATH}
    to
    ExtraPath c:/iPlanet/examples/foo-dir/natlib;C:/iPlanet/Servers/bin/https/bin;${NSES_JRE_RUNTIME_LIBPATH}
    (g) Apply changes from the Web Server Administration Console and Restart the web server.
    You should be able to see the behaviour that you want from your application.
    http://yourserver/foo/foo.jsp
    Hope this was helpful!!!
    Sonu

    Deploying a WAR file containing .jsp and servlets (also uses JNI) on Windows 2000
    We had problems making it initially work on Sun ONE Web Server 6.0 Service Pack 1 because of lack of good iPlanet Web
    Server documentation on deploying such files.
    This is how we went about it:
    1) Make one of the servlet and JSP (must call another Java Class) web application (.war) examples work with iPlanet Web
    Server.
    C:\iPlanet\Servers\plugins\servlets\examples\web-apps\HelloWorld\HelloWorld.war
    and
    C:\iPlanet\Servers\plugins\servlets\examples\web-apps\jakarta-examples\jarkarta-examples.war
    a) Go to your Web Server Administration to deploy the application using GUI Web Application Deploy.
    (We usually use command line, we experienced some issues with the GUI version, but maybe it is fixed in the new Web Server
    service packs)
    From browser, open http://yourserver:8888/
    Click on Select a Server:Manage
    Click on Virtual Server Class
    Click on https-yourserver
    Click on the Web Applications Tab
    Then, click on Deploy Web Application
    Enter the following -
    WAR File On: Local
    WAR File Path: C:\iPlanet\Servers\plugins\servlets\examples\web-apps\jakarta-examples\jarkarta-examples.war
    Application URI: /jakarta
    Installation Directory: c:\iPlanet\examples\jakarta-examples
    By clicking on OK it deployed the application.
    I can verify that it is deployed by selecting "Edit Web Applications" and I see the following entry:
    Edit     /jakarta     c:/iPlanet/examples/jakarta-examples
    Also, c:/iPlanet/examples/jakarta-examples should have the similar following directory structure ..
    - [images]
    - [jsp]
    - index.html
    - [servlets]
    - [META-INF]
    - [WEB-INF]
    - [classes]
    - [tlds]
    - web.xml
    - index.html
    I restarted the server and accessed it using the following URL from my IE browser:
    http://yourserver/jakarta/index.html
    Then I clicked on the JSP Examples and tried some JSP examples.
    b) Alternatively, you can also deploy the same example from the command-line.
    Make sure C:\iPlanet\Servers\bin\https\httpadmin\bin\ is in your path
    wdeploy deploy      -u /jakarta
              -i yourserver
              -v https-yourserver
              -d c:\iplanet\examples\jakarta-examples
              C:\iPlanet\Servers\plugins\servlets\examples\web-apps\jakarta-examples\jarkarta-examples.war
    Restart the web server (I don't think you have to restart, but .. might as well).
    2)Deploy your web-application
    My Foo.war has the following structure.
    You can use jar tf Foo.war to look at the file contents from command line (assuming you have JDK installed and the bin is
    in your PATH)
    Foo.war
    - [META-INF]
    - [WEB-INF]
    - web.xml
    - [classes]
    - Bar.class
    - MoServlet.class
    - [lib]
    - ThirdParty.jar
    - [natlib]
    - extlib.dll
    - foo.jsp
    Here is our application scenario:
    foo.jsp uses a class call Bar (it is not in any package). The Bar java class uses classes from ThirdParty.jar. The
    ThirdParty.jar in turn uses JNI to load library extlib.dll. foo.jsp also calls /servlet/Mo as well.
    Now to deploy it, do the following:
    (a) Make sure that within foo.jsp, you import the Bar class ( I don't know why you have to do it, but if you don't you get
    JSP compile error).
    <%@page language="java" import="Bar" contentType="text/html"%>
    (b) Check web.xml (for Servlets)
    Within web.xml, make sure you have the following mappings:
    <servlet>
    <servlet-name> MoLink </servlet-name>
    <servlet-class> MoServlet </servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name> MoLink </servlet-name>
    <url-pattern> /servlet/Mo </url-pattern>
    </servlet-mapping>
    (c) Deploy the application
    Using command line:
    wdeploy deploy      -u /foo
              -i yourserver
              -v https-yourserver
              -d c:\iplanet\examples\foo-dir
              Foo.war
    (d) Change web-apps.xml file (for picking up ThirdParty.jar)
    It is located in
    C:\iPlanet\Servers\https-yourserver\config
    You should see something similar to following after successful deployment.
    <web-app uri="/foo" dir="C:\iPlanet\examples\foo-dir" enable="true"/>
    Change it to look like following to pick up the ThirdParty.jar
    <web-app uri="/foo" dir="C:\iPlanet\examples\foo-dir" enable="true">
    <class-loader reload-interval="300"
              classpath="C:/iPlanet/examples/foo-dir/WEB-INF/lib/ThirdParty.jar"
              delegate="false"/>
    </web-app>
    (e) Change jvm12.conf file (for JNI)
    It is located in
    C:\iPlanet\Servers\https-yourserver\config
    Add or uncomment the following lines:
    #optional - just helps with instrumenting the jsp and servlet code
    jvm.include.CLASSPATH=1
    jvm.enableDebug=1
    nes.jsp.enabledebug=1
    jvm.trace=7
    jvm.verboseMode=1
    #required for JNI
    java.compiler=NONE
    jvm.classpath=.;C:\JDK1.3.1\lib\tools.jar;C:/iPlanet/Servers/plugins/servlets/examples/legacy/beans.10/SDKBeans10.jar;
    jvm.option=-Xrs
    jvm.option=-Xnoagent
    # not sure if this is needed for iPlanet web server
    jvm.option=-Djava.library.path=C:/iPlanet/examples/foo-dir/natlib/ -Djava.compiler=NONE
    (f) Change magnus.conf file (for JNI)
    We HAD to change this file in order for ThirdParty.jar file to pick up the native C++ code using JNI. Apparently, the
    iPlanet Web Server doesn't pick the Environment Variable Path. Because when we had the directory containing the DLL just
    in Path, it didn't work.
    Change Extrapath directive:
    ExtraPath C:/iPlanet/Servers/bin/https/bin;${NSES_JRE_RUNTIME_LIBPATH}
    to
    ExtraPath c:/iPlanet/examples/foo-dir/natlib;C:/iPlanet/Servers/bin/https/bin;${NSES_JRE_RUNTIME_LIBPATH}
    (g) Apply changes from the Web Server Administration Console and Restart the web server.
    You should be able to see the behaviour that you want from your application.
    http://yourserver/foo/foo.jsp
    Hope this was helpful!!!
    Sonu

  • Re: capturing screen resolution in JSP or servlet

    "Mike Tickle" <[email protected]> wrote ...
              > Is it possible to capture screen resolution in JSP or a Servlet? I can
              > currently do it in JavaScript and write the result in to a cookie that a
              > servlet can read, but is there a better solution.
              > Is it possible to get the time zone of a visitor using JSP or servlets?
              > Can JSP or servlets determine if a visitor has scrolled the page to view
              all
              > of it?
              You seem to be very confused about what servlets and JSPs are. These are
              things that run on the server and generate HTML. They can't possibly know
              if a user has scrolled the page, because the user hasn't seen the page yet
              when they are run. If they tried to read screen resolution, they'd get the
              screen resultion for the graphics subsystem on the server, or an exception
              if one isn't available (eg, there is no X display set).
              For these kinds of client interaction tasks, JavaScript is probably still
              your best option.
              Chris Smith
              

    Hey all you non-ASP programmers, here's the deal. Microsoft has a Browser
              Capabilities component and they have defined a special way for you to
              populate a specially named cookie on the client side that will then allow
              the component to pick up what you sent it. In the ASP script, you then use
              the component. Behind the scenes, it works exactly like what you guys
              imagine, but Microsoft provides the format for sending the information and
              the parsing.
              The client side script does need to be written to include the information
              you want, but it would typically be written once and hidden by the lead
              programmer in a common include file where most programmers never had to
              think about it and thus might think it happened automatically.
              If you're really curious, here's an MSDN link to the details:
              http://msdn.microsoft.com/library/psdk/iisref/comp1vol.htm.
              Rick Joi, former ASP developer
              [email protected]
              www.rickanddonna.com/ips
              "Chris Smith" <[email protected]> wrote in message
              news:[email protected]...
              > "Mike Tickle" <[email protected]> wrote ...
              > > > You seem to be very confused about what servlets and JSPs are.
              > >
              > > I am quite familiar with servlets as I have been using them for 6 months
              > as
              > > part of a uni project. I had the presentation yesterday and the
              moderator
              > > asked why I used JavaScript to determine time zone and screen res. I
              said
              > > JSP/Servlets can not do it as they are server side and he seemed
              confused.
              >
              > Okay. Apologies if I was condescending. Such things happen in newsgroups
              > where I have no idea what your background is.
              >
              > > Apparently ASP can do it. So against my better judgement I thought I
              > would
              > > ask in case I was wrong.
              >
              > I'm surprised if ASP can do it... I can't imagine how that occurs. I
              agree
              > with Jeff, especially after reading the URL he provided; it appears the
              > moderator was just plain wrong, or that there are only very non-portable
              > solutions for IE only.
              >
              > > I currently write the time zone and screen resolution in to a session
              > cookie
              > > so that it can be read every time the servlet is run. Is there a better
              > way
              > > than this?
              >
              > Seems to me like the best way to me.
              >
              > Chris Smith
              >
              >
              >
              

  • Deploying web applications - jsp generated servlet's may be written over the same file!

    Hi, I have made the following test:
    Created two simple web applications with one jsp page, and deployed it
    with different context names, in weblogic.properties I have:
    weblogic.httpd.webApp.weirdApp=\java\weblogic\myserver\weirdApp.war
    weblogic.httpd.webApp.weirdAppTwo=\java\weblogic\myserver\weirdAppTwo.war
    (Note: I have used two diferent war files, because I have a different
    implementation of the jsp page, I could have used the same warfile, and
    deployed it two times with the same different names I have used)
    These two applications have a jsp named myHomePage.jsp
    If I access the first application, like this:
    http://myServer:7001/weirdApp/myHomePage.jsp
    the servlet for myHomePage is created in
    /java/weblogic/myserver/WEB-INF/_tmp_war/jsp_servlet/_myhomepage.class
    If I access the second application, like this:
    http://myServer:7001/weirdAppTwo/myHomePage.jsp
    the servlet for myHomePage is created in
    /java/weblogic/myserver/WEB-INF/_tmp_war/jsp_servlet/_myhomepage.class
    It overrides the first one! Because the servlets are keeped in memory by
    a different class loader this seems to not affect the other servlet, but
    I am wondering what may happen with this strange beaver from weblogic!
    Bruno Antunes,
    Java Software Engineer
    email: mailto:[email protected]
    Phone: +351.21.7994200
    Fax : +351.21.7994242
    WhatEverSoft - Java Center
    Centro de Competencia Java
    Praca de Alvalade, 6 - Piso 4
    1700-036 Lisboa - Portugal
    URL: http://www.whatevernet.com
    ****************** Internet Mail Footer ****************************
    A presente mensagem pode conter Informação considerada Confidencial.
    Se o receptor desta mensagem não for o destinatário indicado, fica
    expressamente proibido de copiar ou endereçar a mensagem a terceiros.
    Em tal situação, o receptor deverá destruir a presente mensagem e
    por gentileza informar o emissor de tal facto.
    Privileged or Confidential Information may be contained in this
    message. If you are not the addressee indicated in this message,
    you may not copy or deliver this message to anyone. In such case,
    you should destroy this message and kindly notify the sender by
    reply email.

    I have a separate java class that gets my data and returns a Result object. Do you mean java.sql.ResultSet?
    In my main servlet I do the following:
    request.setAttribute("supporttracker",
    supporttracker.findsupporttracker(monthYear));
    and then in my JSP I can iterate through the Result
    like the following with no problems:
    <c:forEach var="supporttracker" begin="0"
    items="${supporttracker.rows}" varStatus="counter">
    My problem is that I can only iterate through this
    once in the page whereas I have no problem doing
    multiple forEach loops through other types of
    lists/collections such as an ArrayList. Right, because a ResultSet is a database cursor and doesn't act the same way that an ArrayList does. It's more like an InputStream - once you read it, you close it. If you want to re-read it, you have to re-initialize it again.
    Iterators behave that way, too. Once you walk through them, you have to re-initialize them.
    I've looked
    on the web and in a couple of books, I first thought
    it may be scope or some attribute in forEach that I
    was missing but I'm stumped. It seems like it's
    because the pointer to the result set is at the end
    of the result set when trying the second iteration,
    but I thought by using the begin="0" would put the
    pointer at the first row again, on my second
    iteration I'm getting no rows/data outputed.
    Please help and thanks in advance!The better thing to do is for your method to return a List of objects, one per row, that represent what the ResultSet returns. Have that method iterate through the ResultSet, loading the rows into the List, and close it before you leave in a finally block. A database cursor is a scarce resource, so it's a good idea to close it as soon as you can.
    %

  • Implement SSL in JSP and servlets

    hi there,
    i needed some help in implementing ssl in JSPs and servlets. My idea was to have a login page and also use it where sensitive data is being sent. I have used the basic socket programming (socket.class and serverSocket.class) in GUI applications using threads to listen and send simultaniously and understand how it works but how do I implement it in JSP and servlets and where do i store the certificate?
    i do know that using SSL sockets is very much the same as using the normal sockets.
    can anyone tell me any useful links or give me a step by step guide how to implement it and which classes to use
    your help would be very much appreciated.
    mani

    hi,
    soory for late reply.
    i think you need to use keytool program in your JDK to generate a certificate signature file and you need to configure the server.xml to open and use the HTTPS port. I have not had any additional info on this but i would assume that you simply enter https:// on the file you wish to load in your form and it should use the HTTPS port provided it can find the certificate which must be stored somewhere in your tomcat web server. i would recommend you see tomcat website or search on google for "ssl support in tomcat".i hav not had time to look into this but i will as soon as i am free from my work load.
    mani

  • JSP and Servlets? What's the difference?

    I've got this book, and it's mixing servlet with jsp and then jsp with servlet. Can we just use one and still make a web application? What is the difference between the both? Can anyone give me a basic idea behind these 2 J2ee technologies.

    hi,
    Both use server-side Java to dynamically generate web pages. The source code to a JSP looks like HTML, with Java embedded inside
    (a) normal HTML tags, (b) JSP tags like <jsp:include>, (c) custom tags, (d) scriptlets (Java code surrounded with <% and %>).
    The source code to a servlet looks like Java, with HTML embedded in out.print(...) statements. Both use the Servlet API to communicate with the web server and the client. In fact, a JSP gets compiled into a servlet, so they're almost identical in terms of expressive power. The choice is, whether you're more comfortable coding your pages in Java or in JSP-style HTML; and since you can call a JSP from a Servlet and vice versa, you don't have to make an either-or decision.
    Karthick PalaniChamy

  • Basic jsp and servlet question (JSP Model 2)

    Hi
    I want to make an website where i use JSP Model 2 architecture. However I got a basic question
    1. I need to separate business logic from presentation with the use of jsp and servlets. Meaning I want no html code in the servlet. Can you give a simple example of how this can be done? If I map my implementation of httpServlet to a jsp page in web.xml and override doPost() and doGet(). The calls to the jsp page comes to the servlet as it should. I want to process some methods (calling sessionbeans or similar which in turn calls entitybeans) and then show the jsp page.
    How do I show the jsp page without mixing html in the servlet as I've done below:
    doGet(HttpServletRequest req, HttpServletResponse res)
    PrintWriter p = response.getWriter();
    p.print("<html><body>Hello world</body></html>"); //I dont want to do //this, I want to display the JSP site
    doPost(HttpServletRequest req, HttpServletResponse res)
    //doSomething
    }Message was edited by:
    CbbLe

    You should treat your servlet class much like a controller, where you can then use JSP as the view. The way you achieve this is to use the forward() method in RequestDispatcher.
    Say you've got a servlet class org.yoursite.controller.YourController:
    public void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
      //Set some value for use in the JSP file associated wth me
      req.setAttribute("greeting", "Hello world!");
      //Done with our business logic, off we go to the JSP file
      ServletContext app = getServletContext();
        RequestDispatcher disp;
        disp = app.getRequestDispatcher("/some/jsp/file.jsp);
        disp.forward(req, resp);
    }Now in your JSP file:
    <h1>Example</h1>
    <div>
      I just want to say <%= request.getAttribute("greeting") %>
    </div>Going to that servlet now executes business logic and then points to the JSP file for the view. You can forward from servlet to servlet too if needs be. The string you pass to forward() is whatever would be in the URI of the request so any <servlet-mapping> configurations in web.xml are used ;)
    There is some pretty in-depth documentation on the J2EE blueprints website, namely service-to-worker and front-controller patterns. I dare say if you're looking for this sort of code you'll want to look at the composite view pattern too (also on blueprints).

  • How to post an audio file in JSP or servlet

    Hi,
    I've loaded some rm files into the database. How do I retrieve and post it to the web using JSP or servlet page? How do I convert the ORDAUDIO to BLOB field? I went to the following example/demo:
    http://www.oracle.com/technology/sample_code/products/intermedia/index.html
    but didn't gain much help. Please provide me some sample codes using embeded tag. Thanks!
    Regards,
    Johnny

    I''l try again.....
    The response to your http page does not include media of any kind. The media is not part of your web response. It takes another request to get the media.
    Your embed tag, image tag, object tag, anchor tag only reference the media data. Typically , in the case of an image, by a relative URL.
    Your OrdAudio object can only provide the mimetype and other metadata when you are building your web page. You must have another endpoint to handle the delivery of binary media.
    A simple servlet is typically used, Consider the following servlet. It delivers a HTML form, or Image media, depending on what the request parameter "what" is set to. If "what" is set to "form", it delivers an HTTP form that references this same servlet, except that in the image tag "what" is set to image, where the image object is fetched, and the binary media delivered (with the right mimetype). Just change the Image stuff to audio, the html image tag to an anchor or embed tag, and something like this should work for audio as well.
    This is a bit better... , the <img src= is messed up, as are the <h1> tags...
    import java.io.IOException;
    import java.io.PrintWriter;
    import java.sql.Connection;
    import java.sql.SQLException;
    import java.sql.Types;
    import java.sql.PreparedStatement;
    import javax.servlet.ServletException;
    import javax.servlet.ServletConfig;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.naming.NamingException;
    import oracle.jdbc.OracleResultSet;
    import oracle.jdbc.pool.OracleConnectionPoolDataSource;
    import oracle.jdbc.pool.OraclePooledConnection;
    import oracle.jdbc.driver.OracleConnection;
    import oracle.ord.im.OrdImage;
    import oracle.ord.im.OrdHttpResponseHandler;
    import oracle.ord.im.OrdMultipartWrapper;
    public class deliveryServlet extends HttpServlet
        OracleConnection conn = null;
        String servletURL = null;
         * Servlet initialization method.
        public void init( ServletConfig config ) throws ServletException
            super.init(config);
         * Get a pooled database connection
        private void getPooledConnection() throws SQLException, NamingException
            javax.naming.InitialContext ic = new javax.naming.InitialContext();
            OracleConnectionPoolDataSource ds = (OracleConnectionPoolDataSource)
                    ic.lookup("jdbc/pool/OracleMediaPoolDS");
            OraclePooledConnection pc = (OraclePooledConnection)
                                     ds.getPooledConnection();
            conn = (OracleConnection)pc.getConnection();
            // conn.setAutoCommit(false); // just query. No need for this
         * Process an HTTP GET request used to deliver an image column
        public void doGet( HttpServletRequest request,
                            HttpServletResponse response )
            throws ServletException, IOException
          String id = request.getParameter( "id" );
          String what = request.getParameter( "what" );
          if (!"image".equalsIgnoreCase(what)) what = "form"; // set a default
          if ("form".equalsIgnoreCase(what))
         String servletURL = request.getRequestURL().toString();
            try
           if (conn == null) getPooledConnection();
              PrintWriter out = response.getWriter();
              response.setContentType( "text/html" );
              out.println( "<HTML><BODY>" +
             "<H1>Display Images</H1>" +
                "<FORM action=\"" + servletURL + "\">" +
                " Enter Row ID:<INPUT type=\"text\" name=\"id\" /><BR/>");
              if (id != null)
                PreparedStatement stmt =
                  conn.prepareStatement("select description, location, " +
                                               "thumb, image "+
                                      " from photos where id = ?" );
                stmt.setString( 1, id );
                OracleResultSet rset = (OracleResultSet)stmt.executeQuery();
                // Fetch the row from the result set.
                if ( rset.next() )
                  // Get columns from query
               String location = rset.getString(1);
               String description = rset.getString(2);
                  OrdImage thumb =
                     (OrdImage)rset.getORAData(3, OrdImage.getORADataFactory());
                  OrdImage img =
                     (OrdImage)rset.getORAData(4, OrdImage.getORADataFactory());
                  out.println("<B>Description: </B>" + description+ "<BR/>");
                  out.println("<B>Location: </B>" + location+ "<BR/>");
                  if (thumb != null && thumb.getMimeType().startsWith("image/"))
                    String thmbWidthStr =  thumb.getWidth() == 0 ? "" :
                                      "WIDTH=\"" + thumb.getWidth()  + "\" ";
                    String thmbHeightStr =  thumb.getHeight() == 0 ? "" :
                                      "HEIGHT=\"" + thumb.getHeight()  + "\" ";
                    out.println("<B>Thumbnail: </B>" +
                                "<IMG SRC=\"" + servletURL + "?id=" + id +
                                         "&what=image&col=thumb\" " +
                                         thmbWidthStr +
                                         thmbHeightStr +
                                 "/>" );
                  if (img != null && img.getMimeType().startsWith("image/"))
                    String imgWidthStr =  img.getWidth() == 0 ? "" :
                                      "WIDTH=\"" + img.getWidth()  + "\" ";
                    String imgHeightStr =  img.getHeight() == 0 ? "" :
                                      "HEIGHT=\"" + img.getHeight()  + "\" ";
                    out.println("<B>Image: </B>" +
                                "<IMG SRC=\"" + servletURL + "?id=" + id +
                                         "&what=image&col=image\" " +
                                         imgWidthStr +
                                         imgHeightStr +
                                 "/>" );
                else
                  // Print not found
                  out.println("<H2>Row with ID\"" + id + "\" Not Found</H2><BR/>");
              out.println("</FORM></BODY></HTML>");
            catch (Exception e)
           conn  = null; // Get another connection next time.
              throw new ServletException(e);
          else
            try
           if (conn == null) getPooledConnection();
              String col = request.getParameter("col");
              if (col == null) col = "thumb"; // default to the thumbnail column
              PreparedStatement stmt =
                conn.prepareStatement( "select " + col +
                                       " from photos where id = ? " );
              stmt.setString( 1, id );
              OracleResultSet rset = (OracleResultSet)stmt.executeQuery();
              // Fetch the row from the result set.
              if ( rset.next() )
                // Get the OrdImage object from the result set.
                OrdImage img =
                     (OrdImage)rset.getORAData(1, OrdImage.getORADataFactory());
                // Create an OrdHttpResponseHandler object, then use it to retrieve
                // the image from the database and deliver it to the browser.
                OrdHttpResponseHandler handler =
                    new OrdHttpResponseHandler( request, response );
                handler.sendImage( img );
              else
                // Row not found, return a suitable error.
                response.setStatus( response.SC_NOT_FOUND );
              // Close the result-set and the statement.
              rset.close();
              stmt.close();
            catch (Exception e)
           conn  = null; // Get another connection next time.
              throw new ServletException(e);

  • Applet in jsp from servlet, but error: ClassNotFoundExcep

    The problem that I'm having is already mentioned a couple of times in this forum, but unfortunately I haven't found a solution, in thread http://forum.java.sun.com/thread.jspa?forumID=33&threadID=239405 is proposed solution but it's not working for me.
    I'm developing a project in IBM's Websphere Developer Studio 5.1.1. and JRE that I'm using for this project is 1.4.2. I have created servlet "CompanyDocument.java" and applet "SimpleApplet.java". Applet was created as single project and then imported into this one, that means that it's contained in current project as "SimpleAppletPackage.jar". I have placed jar in folder "Applets", Websphere automatically creates folder "simpleAppletPackage" and in it's root complied "SimpleApplet.class".
    When I put following code in the jsp page applet works correctly when application is runed.
    <APPLET code="simpleAppletPackage/SimpleApplet.class" codebase="Applets" archive="SimpleAppletPackage.jar" width="250" height="250"></APPLET>
    But I wanted to create jsp from servlet. So I used this code within servlet:
    out.print("<APPLET code=\"simpleAppletPackage/SimpleApplet.class\" codebase=\"Applets\"");
    out.print("archive=\"SimpleAppletPackage.jar\" width=\"250\" height=\"250\"></APPLET>");
    But I get an error (when running, no error when compiling). The error is copied from Java console:
    load: class simpleAppletPackage/SimpleApplet.class not found.
    java.lang.ClassNotFoundException: simpleAppletPackage.SimpleApplet.class
    at sun.applet.AppletClassLoader.findClass AppletClassLoader.java:162)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
    at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:123)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
    at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:566)
    at sun.applet.AppletPanel.createApplet(AppletPanel.java:619)
    at sun.plugin.AppletViewer.createApplet(Unknown Source)
    at sun.applet.AppletPanel.runLoader(AppletPanel.java:548)
    at sun.applet.AppletPanel.run(AppletPanel.java:299)
    at java.lang.Thread.run(Thread.java:534)
    Caused by: java.io.IOException: open HTTP connection failed.
    at sun.applet.AppletClassLoader.getBytes(AppletClassLoader.java:265)
    at sun.applet.AppletClassLoader.access$100(AppletClassLoader.java:43)
    at sun.applet.AppletClassLoader$1.run(AppletClassLoader.java:152)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:149)
    ... 9 more
    In the same time I'm creating some more code from servlet and it works with no errors and is shown in browser properly (it consists of connection to Oracle, formatting table, and presenting data within that table).
    Any idea? I'm totally stuck.

    In your browser, look at the HTML code that gets sent to the browser and see if there is something wrong with it.
    Specifically, I would look at the code near the <APPLET ..></APPLET> tags, both before and after and look for stray quotes, brackets, or what not.
    Finally, I would look inside the <APPLET ...> tag. It appears to me that the output will probably be:
    <APPLET code="simpleAppletPackage/SimpleApplet.class" codebase="Applets"archive="SimpleAppletPackage.jar" width="250" height="250"></APPLET>See, you may be missing a space between the "Applets" and the archive=. Try making the second out.print look like this:
    out.print(" archive=\"SimpleAppletPackage.jar\" width=\"250\" height=\"250\"></APPLET>"); See the extra space at the start of the output?

  • Oracle 10g XE in tomcat 5.5 through JSP or Servlet

    Hello iam very new user of tomcat,oracle 10g .Will you please guide how to set environment variables and any other modifications to be done to run a JSP or Servlet including JDBC(oracle 10gXE) connection in tomcat5.5 for windows Xp.
    Please tell me in detail........................................

    I am sure that one can set up SELinux 'properly'.
    Everyone I talk to about SELinux tells me that it has become more detailed and much more 'secure' in that past years, and that probably explains why Oracle worked easily in FC3 and not so easily now. The added power also requires added configuration, which some have described to me as 'somewhat more involved than sendmail.cf'
    The documentation is at http://www.nsa.gov/selinux/ for those who wish to learn about the configuration capabilities. I'm sure that Google will also provide tutorials.

  • Help,JSP and SERVLETS!

    hello:
    i've downloaded ECLIPSE 3.2,TOMCAT 5.5 .
    i tried to build simples examples o servlets but i failed could you please tell me how to proceed?i'm new at this plus i've got a project to do with all this so plz can you give some links to go,i tried but no links was clear.
    i've got to give to my professor an examples executed (servlets,jsp)
    thank you

    HISSO wrote:
    i wil give up on talking about stupid gossip
    you must act professional and i you can't help it's ok
    so plz i juste want help
    i'm so busy finishing my studies
    when it comes to talk about development with tomcat and eclipse together i'm new so i need some advices,so plz let's be serious!
    i'm working hard to finish my project!Try to communicate less like a monkey with electrodes attached to it's genitals. This means stop using words like "plz" and write "please" instead.
    If you want specific help with a specific problem then you should ask a specific question. "help, JSP and SERVLETS" is not a specific question. And you should also note that if your specific question is about Tomcat specifically or Eclipse specifically then you are in the wrong place to begin with.
    So do you want to try again?

Maybe you are looking for

  • Automated Testing of Forte Applications

    Dear Jim, This is a technical and education Forum and I want to make sure everyone is "educated" to your options out there. Our company specific purposes is delivering testing solutions for Forte Developed applications. (Primary responsibility is to

  • Error 1327 Invalid Drive

    i tunes will not play any songs . the songs are there but when i press play nothing happens the maxtor external drive is the problem but im stuck have removed drive downloaded latest itunes still no joy

  • Get full path in an inputFile

    Hi! I´ve inserted an inputFile component in a JSF Page. In the backing bean, I need to get the full path of the selected file in that inputFile, but I´m only able to get the fileName casting the inputFile to an UploadedFile. How can I get the full pa

  • HP 2475w Issue-Image "Shakes"

    Hello,  I recently picked up a second 2475w LCD on the used market and after a week of using it, I have noticed a very minor but constant shaking of the image. The shaking seems slightly more pronounced when using an HDMI cable when compared to a DVI

  • Oracle 8i install on 2000 terminal server

    I seem to have a problem with my install on our terminal server. As I run the setup, it just fails. No errors or fanfair just stopps. Nothing in the even logs and I've tried all (I think) the setup.exe's on the CDROM. Can someone help me with this? P