Oas9i AS and Servlet

Dear OTN Readers and Oracle Support,
I am using OAS9i AS with Oracle 8i Database. I have some basic
questions:
1. Is there a way to deploy applications without using sess_sh
tool like some GUI frontend.
2. OAS9i has many ways to run servlets: JServ, OSE and
OC4J/J2EE.
Jserv do not even implement the current Servlet Specs although
OAS 4.8 used to and Apache have not updated it for a long
time. Is this okay to use Jserv or we should move to other
technology like OSE/OC4J.
3. How do we set session time outs in Servlets in OSE?
I did not find a way to read the config variables found
in wedcontexts. The only config value that I can read from
servlets is the ones defines while using publishservlet
command in sess_sh.
Please help. My email is: [email protected]
Thanks a lot,
Surendra

Anatoly,
You can request for AS but I am not sure if you will get IPv4 public space or not. Which location are you from? If Asia then you will need to contact APNIC and looks difficult to get IPv4 space since it is exausted. You will have to take IPv6 public space for the Internet connectivity. Time to upgrade your network to support IPv6 internet now. Also you will need to make sure that your hosts(PC) are capable of supporting IPv4 & IPv6 both stacks.
Also I assume that you want to do 6to4 NAT because NAT-PT has already been deprecated. NAT64 mechanism is generally used for the site-site communication or VPN traffic. I am not sure if you can use this for the Internet. Internet will have native IPv4 or IPv6 connectivity whether you perform private V4 to Internet V4 NAT or Site-local V6 to Internet V6 NAT.
I don't think you can do private V4 to public V6 NAT. Mean while you can have a small V4 subnet from your ISP and PAT all of your internal traffic to the Internet.
Regards,
Deepak Ambotkar

Similar Messages

  • Need some help with Slow Downs in Java3D and Servlets

    Hi,
    I realize that there is a separate forum for Java 3D, but I posted there, and did not get any response. This is kinda the crux of my program, so I would like to invite anybody on this forum with knowledge of Java 3D and servlets to give it a stab. Between this post and that one, there are TWENTY duke dollars up for grabs.
    Thanks.
    http://forum.java.sun.com/thread.jspa?threadID=603198

    Let me have an educated guess.
    You calculated the time elapsed before sending in a server request - and at that point you have you updated timeLastStateChange yet, which means by the time of the next calculation of time elapsed this apparent delay is not counted in, hence the slow down in animation rate.
    Hope this helps~
    Alex Lam S.L.

  • Web service and servlets in the same project...web.xml?

    Hello, I have a problem with my web service.
    I have a server, which displays a web service. I programmed this service with JAXRPC.
    I have a client, in another directory. I succeded in compiling, deploying and running the web service.
    The problem is that after I tried to integrate this service in an existing project. This project contains servlets. In these servlets, I'm using sessions.
    These servlets are on the same side as the server of the web service. Because of the implementation of my code, I'd like to use in the class that represents the server of the service, the same session as the one I'm using in the servlets.
    But of course, it's not working by itself. I know there's something to do with the web.xml files.
    The thing is that I created a web.xml file for the service, and another for the servlets.
    I was thinking of joining both of them in one xml file, but everything crashes then...
    Could someone tell me how to create a project with a web service and servlets, and mostly how to configure the xml file??
    Thanks for any help
    Philippe

    Hello, I have a problem with my web service.
    I have a server, which displays a web service. I programmed this service with JAXRPC.
    I have a client, in another directory. I succeded in compiling, deploying and running the web service.
    The problem is that after I tried to integrate this service in an existing project. This project contains servlets. In these servlets, I'm using sessions.
    These servlets are on the same side as the server of the web service. Because of the implementation of my code, I'd like to use in the class that represents the server of the service, the same session as the one I'm using in the servlets.
    But of course, it's not working by itself. I know there's something to do with the web.xml files.
    The thing is that I created a web.xml file for the service, and another for the servlets.
    I was thinking of joining both of them in one xml file, but everything crashes then...
    Could someone tell me how to create a project with a web service and servlets, and mostly how to configure the xml file??
    Thanks for any help
    Philippe

  • 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

  • Need help in JSP and Servlets

    Hi friends,
    [please forgive me if i am posting this in the wrong forum, all seems same to a fresher]
    Now, to my problem..i need a suggestion, a way or a method to implement the following!
    I am supposed to create a servlet that reads data from oracle database. Once i retrive the data (for example: 6 rows of a table having 4 attributes), i am supposed to pass this data to a JSP page where the data has to be formatted and displayed properly. If i call the same servlet from a different JSP, i should be able to access the data in that JSP and format it in a different way. How do i pass the data to JSP? what method i can use to achieve this task?
    Note: I already know about PrintWriter pw = response.getWriter(); and then printing the formated HTML page..but i want to keep the formatting to JSP part and send only the data part that i can access in JSP
    Thanks in adavance

    arun_ramachandran wrote:
    [please forgive me if i am posting this in the wrong forum, all seems same to a fresher]Then you should learn to be more observant - after all, we have JSP and Servlet fora, further down the list. :)
    I am supposed to create a servlet that reads data from oracle database. Once i retrive the data (for example: 6 rows of a table having 4 attributes), i am supposed to pass this data to a JSP page where the data has to be formatted and displayed properly. If i call the same servlet from a different JSP, i should be able to access the data in that JSP and format it in a different way. How do i pass the data to JSP? what method i can use to achieve this task? You can store the data in your session object. You can even use JavaBeans and the jsp:usebean tag.
    [http://java.sun.com/products/jsp/tags/11/syntaxref11.fm14.html]
    Note: I already know about PrintWriter pw = response.getWriter(); and then printing the formated HTML page..but i want to keep the formatting to JSP part and send only the data part that i can access in JSPA wise approach - I wish more prople woiuld be as thoughtful.

  • How to upload a file into server using j2ee jsp and servlet with bean?

    How to upload a file into server using j2ee jsp and servlet with bean? Please give me the reference or url about how to do that. If related to struts is more suitable.
    Anyone help me please!

    u don't need j2ee and struts to do file uploading. An example is as such
    in JSP. u use the <input> file tag like
    <input type="file"....>You need a bean to capture the file contents like
    class FileUploadObj {
        private FormFile srcFile;
        private byte[] fileContent;
        // all the getter and setter methods
    }Then in the servlet, you process the file for uploading
        * The following loads the uploaded binary data into a byte Array.
        FileUploadObj form = new FileUploadObj();
        byte[] byteArr = null;
        if (form.signFile != null) {
            int filesize = form.srcFile.getFileSize();
            byteArr = new byte[filesize];
            ByteArrayInputStream bytein = new ByteArrayInputStream (form.srcFile.getFileData());
            bytein.read(byteArr);
            bytein.close();
            form.setFileContent(byteArr);
        // Write file content using Writer class into the destination file in the server.
        ...

  • 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

  • How to set classpath to EJB and Servlets

    Hi all,
    How can I add a classpath to EJB and Servlets in Weblogic 6.1, so that that classpath
    can be achieved by both EJB jar and war file? I have deployed a .ear file having
    the jar and war files. Now the EJBs inside the jar file are not reaching the class
    files of the war file and the class files in the war file are not reaching to
    the EJBs. Please let me know at the earliest.
    Atanu

    Hi.
    You might try looking at the petstore example which combines webapps (war files) with
    ejbs in an ear file to see how to do this. It may be a simple config problem.
    Regards,
    Michael
    Atanu Dey wrote:
    Hi all,
    How can I add a classpath to EJB and Servlets in Weblogic 6.1, so that that classpath
    can be achieved by both EJB jar and war file? I have deployed a .ear file having
    the jar and war files. Now the EJBs inside the jar file are not reaching the class
    files of the war file and the class files in the war file are not reaching to
    the EJBs. Please let me know at the earliest.
    Atanu--
    Michael Young
    Developer Relations Engineer
    BEA Support

  • How to setup my computer to run JSP and Servlets

    I want to setup my computer to run JSP and Servlets.
    What kind of Servers and other tool i need to install to run JSP and Servlets.
    Plz, Help me to start my work on JSP.
    Regards,
    Usman Ali

    hello
    JSP and servlet is web programming, may be little bit different to development local application.
    1st, you should have two computers: one is server and the other is local workstation. This server should have a static IP address, that other people can go into your server. Workstation is any computer normal you use it.
    2nd, you need to setup your server in: OS(linux or windows 2000), web server (jrun, apach or Tomcat etc. ), as well as install JDK, servlet.
    3rd, your local workstation just use as programming editor and open a browser to testing, anytime you write your code, then ftp to server to test.
    Reality, you have many technical thing to solve, eg setup web server etc. However, you can write your source code and test it, then open to outside people.
    hope to helpness, if anything don't uderstand, you can post again or send email to me [email protected] Since I just have setup this configuration in my university for my project.

  • Load balancing for JSPs and servlets

    Hi:
              I am using IIS as the proxy server, with the WLS plug-in, to a WLS
              cluster. This provides round robin load balancing just fine. Will it
              provide weight based load balancing if I set 'weblogic.system.weight'
              differently on each server, or is that not relevant for clustering JSPs
              and servlets?
              Sincerely,
              Ashish
              

    Currently the plugins ( for NES, IIS and Apache) just use the round robin
              algorithm. the property
              weblogic.system.weight is used only be weblogic's replica aware clusterable
              RMI/EJB stubs.
              To use this property for your JSP/Servlet load balancing you have to use
              weblogic server as proxy fron-ending your weblogic cluster.
              --Viresh Garg
              Ashish Vimal wrote:
              > Hi:
              > I am using IIS as the proxy server, with the WLS plug-in, to a WLS
              > cluster. This provides round robin load balancing just fine. Will it
              > provide weight based load balancing if I set 'weblogic.system.weight'
              > differently on each server, or is that not relevant for clustering JSPs
              > and servlets?
              > Sincerely,
              > Ashish
              

  • Which tutorials may you suggest for JDBC and servlets?

    Hello, i would to learn about JDBC and servlets.
    May you please suggest me a good tutorial(e.g.post me a link) in order to study for JDBC and servlets?
    e.g. How to make a servlet etc.
    Thanks, in advance!

    I agree with PhHein, it's best to learn one technology and then the other. (Just my two cents, but start with JDBC from a simple standalone application, then when that is working, try to tackle Servlets, since you will need to also learn how to get them working in a container like Tomcat).
    Here is a tutorial that has both concepts in it at the same time. Site is down now, but is usually up. http://www.roseindia.net/jdbc/jdbcconnectivity.shtml
    Also, you will eventually want to download a J2EE container such as Tomcat or Jboss.
    - Saish

  • 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).

  • EJB and Servlets

    Hi there,
    A frontend processing of HTTP request that pass thru WebLogic server that make
    API calls thru tuxedo to the application servers that eventually running C, C++
    that retrieve data from a backend database of Oracle.
    Being the services of EJB and Servlets, EJB is more kind of processes inside the
    server but Servlets can handle better in request and respond (talk to the client),
    whats your opinions in this kind of integration? Go for pure EJB or Servlets?
    Or shall mixed matched? and how should the architecture should looks like?
    Thanks
    Neo

    Sorry, wrong question, just ignore it.

  • Third-party jars not visible to EJB's and servlets.

    Hi, This is an unanswered post in an newsgroup which exactly displays our
    current problem,
    Extract Begins -->
    "I've got a WebApp with classloading issues while running WebLogic 5.1.
    According to the JSDK 2.2 API, if I include third-party classes in
    WEB-INF/lib, my EJBs and servlets should be able to load any jar'ed classes
    inside. In practice, however, it seems to make no difference. My EJB always
    comes back with a NoClassDefFound error for xerces.jar that's in WEB-INF/lib
    (and I've even tried adding it to the EJB JAR itself with no change).Of
    course, if I put Xerces in the server's classpath, there are no problems but
    that's a road I don't want to go down.How can I tell my EJB's to load
    third-party classes from the WEB-INF/lib directory of the WAR file? I'd
    appreciate your insight. <-- End
    We are busy migrating one of our apps from 5.1 to 6.1, What we have done
    thus far and fairly successfully is the following,
    We packaged all the jsps, WEB-INF, html, images into a WAR file and then
    packed all EJB's, META-INF and classes to which the ejbs refer, into an EAR
    file.
    EMARKET_APPS/
    +myjsp.jsp
    +myhtml.html
    +images
    +WEB-INF/+
    |
    +classes/+
    |
    +myclass1.class
    +myclass2.class
    |
    +lib/+
    |
    +OReily.jar
    +jts.jar
    +xerces-1_4_1.jar
    +junit.jar
    +jcschart110Kwl.jar
    |
    +web.xml
    +weblogic.xml
    +META-INF/+
    |
    +applications.xml
    +ejbs/+
    |
    +myejb1.jar
    +myejb2.jar
    +lib/+
    |
    +classes.jar
    Please advise.
    Rgs Roly

    Have you tried to include the jars in the Class path entry in the manifest file.
    That should work eventhough I haven't tried it yet (fighting with ear deployement
    and I must say WLS seems to be winning). I'll get back to when I've tried it.
    There is a VERY good article on theserverside.com regarding class loaders and
    EAR/WAR/EJBs at http://www.theserverside.com/resources/articles/J2EE-Deployment/chapter.html
    Good luck
    /erik

  • MVC JSP and Servlets

    I'm creating JSP pages to represent the view of the site and servlets to get the request and decide which JSP page to load next.
    When the servlet recibes a request it generally has to query the database to get some data and then show it back to the client. To do this the servlet calls other object that is responsible to query the database and fill a ResultSet.
    My question is: what is better, to load a Vector with special objects containing the data in the ResultSet and then return this vector to the jsp page for it to use it, or may a return directly the ResultSet to the jsp page? With the first option I have to cycle in the resultSet to load the vector and then cycle through the vector to show the results. With the second option I cycle only once, but I isolate from the database (column names, order in which the things are returned...)
    I hope anybody can give me an opinion.
    Thanks

    There are a few things wrong with this:
    1) MVC -> The View should have no Model work init.
    For the MVC pattern, the database is Model. Use
    a
    a ResultSet in JSP, and now your View is lockedto
    a
    database with a specific column format.
    Huh? I think that's backwards. The View willalmost
    always require Model data unless it is a staticpage.
    The Model, however, should be agnostic about what
    t View technology it serves. (The Controllerbridges
    the two). Also, I would call the database the
    Persistence or Integration tier, a separateconcept
    from the Model, though intimately coupled to it.I meant the work of the model (gathering the data to
    a presentable form) is moved to the View. Yes, the
    View needs to know the Model to be able to display
    its data. But the Model should handle the data
    collection.
    Fair enough. I might have read it backwards as well.
    >>
    2) Any web application (or any application in
    general) wether it uses MVC or not, should still
    follow a 3 tier approach: Persistance (Data),Domain
    (logic), Presentation (View, output) (note, thisis
    different then MVC.) By moving the ResultSet inthe
    JSP you would be dragging the Persistancemechanism
    up two layers. Generally, a layer should only
    see
    the layer just below it (Presentation seesDomain.
    Domain sees Persistance. Persistance never sees
    s Domain or Presentation. Domain never sees
    Presentation. Presentation never seesPersistance).
    >
    I agree that Persistence and View should not seeeach
    other. However, Model and Persistence must. How
    else do you write a DAO? Or even use a mapperlike
    Hibernate?First the Model doesn't fit into just one of the
    three tiers (Persistance Domain and Presentation).
    The Model of MVC is both the Domain logic and the
    e Persistance mechanism.
    To me, at least, Domain logic = model. The terms I have normally read is either "business tier" or "model domain". "Patterns of Enterprise Application Architecture", M. Fowler. Though, I will concede that this tier has the least well defined set of terms.
    But for the three tier architecture: the domain sees
    the persistance. You always see one layer down. So
    Domain sees the persistance and pulls the data into
    the model. So a DAO would be part of the Domain, the
    logic of collecting the data from the database to be
    used in the application (in the correct object graph
    and all that). The persistance though, doesn't see
    the domain.
    Hmm, I'm not sure which direction 'down' is. And even if 'down' meant towards the back-end or away from it, what about the controller? It parses view requests and delegates them to the model. The results are then normally returned to the controller for dispatch to a view. So, the controller seems to have its fingers in all the tiers except integration and persistence, at least to me. I think of the controller as the 'middle man' between model and view that lets the model be agnostic to the view. The view and controller will to some extent always be coupled. However, the model theoretically exists on its own.
    Half of me thinks that I have a different view on
    where the Domain and Persistance border is. I
    thought the DAO or the Data Mapper would be in the
    Domain, whereas you seem to be saying they are in the
    Persistance layer?
    That's interesting. I don't know if there is an absolute answer. We are dealing with the O/R boundary, and the DAO straddles the boundary. However, one could, at least theoretically, change persistence strategies. What would change? Not your model objects, but your persistence tier objects. Though, again, the definition is nebulous.
    3) From a Practical matter:
    In many DBs, if you close the connection fromwhich
    the ResultSet was derived, the ResultSet is
    closed
    and you get errors if you try to access it. Ifyou
    don't close the connection in the Servlet beforeyour
    JSP, then you have to do it in the JSP. Thatmeans
    even more DB bleed through to the JSP, and theM->V.
    Or, you could just not close the Connection and
    d allow it to hang around and create memory
    leaks.
    >
    Yepper.
    4) Also practical:
    To use the ResultSet in JSP is going to require
    scriptlet code. This is ugly and hard to manageand
    update later. You have to wrap your code in
    try{}catch(SQLException e) {} finally {}, so
    the
    code is even uglier and harder to manage(especially
    if you end up not touching the thing for monthsand
    forget what you had done - or god forbid someoneelse
    has to keep up your code). You could make acustom
    tag to handle it, which makes the JSP easier toread,
    but does further damage of spreading the dataaccess
    code all over the application.
    Definitely!
    5) Practical:
    When you do this sort of thing, then later
    decide
    to
    change the way the database is set up, digging
    all
    the places affected by the simple renaming of a
    column, or refactoring of which columns are inwhich
    tables becomes a heavy effort. Keep it all in a
    DataAccessObject, and changes in DB becomestrivial
    to keep track of in your code. It is all in one
    place, and can be tested off line. Harder stillis
    if you change persistance from a database to anXML
    library, or some directory lookup or something.You
    would have to completely refactor your Servlet
    and
    your JSP. Put it in a DataAccessObject and allyou
    have to do is switch out the DAO instance. The
    change is transparent to the Servlet and the JSPas
    long as you maintain an interface.
    Just keep in mind that for the vast majority of
    projects, the RDBMS technology is rarely switched.I
    generally program to interfaces in my Model, butmy
    Persistence tier is always so tightly coupled thatI
    simply use POJO's without an interface.
    6) Practical:
    I have elluded to this several times, but I will
    state it specifically. When you isolate the
    persistance and data access to its own layer
    then
    you
    can swap out the presentation (the View and the
    Controller) when testing all your persistance
    operations. This means the data is independent
    of
    the container. You can run it out of theServlet/JSP
    environment and it will behave EXACTLY as it
    will
    inside the JSP environment. You can designrobust
    tests, debug, redesign, re-edit, etc... muchquicker.
    Then, when all done, plug it into your web app
    p without worry.
    Great point.
    Of course, Numbers 3 -> 6 are the reasons why
    following 1->2 (MVC and the 3 Tier architecture)are
    such good ideas.- Saish
    BTW, please take all the above just in the interest of having a good discussion. I have been wrong many times before! ;^)
    - Saish

Maybe you are looking for