Choice between JSP and Servlet

I am new to JSP and Servlet. I know JSP container will convert JSP to servlet
eventually. But in application development's standpoint, anything can be
done in servlet can also be done in JSP? Some people told me we can
use the combination of both in one application.
My question is in what situation we use JSP alone, servlet alone, or
combination of both??
Please advise. Thanks!!

Use a combination of both.
Your Web application should have a single servlet that all HTTP requests are POSTed to. All the servlet does is act like a traffic cop: it figures out what the request is, delegates to other objects that do the work, and forward the result to the next JSP, whatever that is. It's called a front controller servlet.
The JSPs should just be pure dynamic presentation. Everything displayed in the pages should have been generated by the servlet and its helper classes. No database queries, etc. Your JSPs will be a lot better off if you learn JSTL and eliminate all scriptlet code.
Check out frameworks like Struts.

Similar Messages

  • Difference between jsp and servlets

    Can any body tell me the difference b/w jsp and servlets.
    As i know one difference is to seperate the java code from html. Is there any other difference. please...

    Servlets are a way to run java on a server. They don't necessarily need to be about HTML or even HTTP. You can write servlets that generate images rather than HTML, for example.
    JSP is a way to create servlets that generate HTML. They get translated into servlets (special-purpose servlets). This is sort of glossing over the details -- the power of JSP is that, by being an intersection between HTML and executed Java code, they can provide a way to clearly differentiate between the two.
    That's a way of looking at it anyway.

  • What is the diff between jsp and servlet

    is thr any other difference betwwen jsp and servlet, tht: jsp is automatic generated servlet and jsp has different types of tag, due this we have write less amount of code.any other technically difference between these two?

    As you mentioned JSP automatically gets converted into a Servlet and then compiled. From the server's perspective other than the transformation process, there is no real difference.
    However, in coding there are some minor differences such as additional access to pre-defined variables and different syntax for some minor things such as imports and etc.
    Perhaps somebody else more knowledgeable can fill you in further.
    Hope that was helpful.

  • Urgent: problem with sharing HttpSession  object between Jsp and servlets.

    Hi,
              We are using weblogic 6.0 sp2.
              I m setting a particular object in session in a servlet using
              session.setAttribute() but when i try to retrieve that object using
              session.getAttribute() in a jsp page the value of that object is null. Is
              there any way to configure HttpSession in weblogic so that jsps and servlet
              can share the same session? Or any workaround for this problem.
              Any help in this regard is appreciated.
              Thanks
              -Shree
              

    Just a guess, but it sounds like you have cookies turned off and are not
              using encodeURL. Try enabling cookies and see if that solves the problem.
              Also, it is generally good practice to use encodeURL to protect yourself
              from users who disable session cookies.
              Here's how we use encodeURL in our Servlets:
              gotoPage("/jsp/someJSP.jsp");
              private void gotoPage( String address,
              HttpServletRequest request,
              HttpServletResponse response )
              throws ServletException, IOException
              RequestDispatcher dispatcher =
              etServletContext().getRequestDispatcher( response.encodeURL( address ));
              dispatcher.forward( request, response );
              "Shree Unde" <[email protected]> wrote in message
              news:[email protected]..
              > Hi,
              > We are using weblogic 6.0 sp2.
              > I m setting a particular object in session in a servlet using
              > session.setAttribute() but when i try to retrieve that object using
              > session.getAttribute() in a jsp page the value of that object is null. Is
              > there any way to configure HttpSession in weblogic so that jsps and
              servlet
              > can share the same session? Or any workaround for this problem.
              > Any help in this regard is appreciated.
              > Thanks
              > -Shree
              >
              >
              

  • Passing session data between jsp and servlet

    I have a servlet that I pass data to my jsp.
    I do a session.setAtrribute in the servlet. No problem.
    I get the data no problem in the jsp that I call.
    How do I pass this same data to the another servlet?
    I basically have an array of values that I already have in the existing jsp that has been set in session.
    When I call the secondary servlet, I don't have anything in this session variable related to my array.
    Prior to posting to my next servlet, do I need to do another setAttribute inside the jsp to get the data passed to the servlet?
    Thanks.

    Two different things. The encoding adds this to the URL (after the page, before the query string
    ;jsessionid=ABC123 but only if the user isn't using cookies.
    So in your example, you would do this (maybe):
    <%
      String url = response.encodeURL("Servlet");
    %>
      <form name="form1" method="post" action="<%= url %>?cmd=pay"> ... Or some modification.
    So the difference between encodeing and using a post is that
    1) encoding adds the jsessionid to the url string if necessary. It does nothing else
    2) POSTing will send a request to the provided URL via the POST method, including the inputs of the form as parameters to the URL.
    They really don't interact with each other. It is like asking what is the difference between the Color Orange and thr Size Big? They can both be applied to the same thing, or not... and have no real relation to each other.

  • Passing parameters between JSP and Servlet

    The scenario is as follows:
    There is a JSP page that sends a string as a hidden parameter to a servlet:
    <input type="hidden" name=<%= Book.NAME %> value=<%= book.getName() %> >
    In the servlet there is a print statement that checks the parameter value:
    System.out.println("Book name: "+request.getParameter(Book.NAME));
    The problem is as follows: if the name of the book consists of more than one word
    such as "Servlets and JSP", the print statement will print only Servlet.
    If the JSP page passes a string directly as shown here:
    <input type="hidden" name="Test" value="Test String" >
    The servlet will print the complete string: Test String
    The same problem appears if the string is passed between two JSP pages.
    Any help is greatly appreciated.
    Regards,
    Basil Mahdi

    You might want to try
    <input type="hidden" name="<%= Book.NAME %>" value="<%=URLEncode.encode(book.getName(), "UTF-8")%>" >This will take care of any wierd un-url friendly charcters that might appear in the book titles such as the ' or " which may be the problem.

  • URL mapping  between jsp and servlet

    recently, I try glassfish, and I get surprised, for example My application name is HelloWorld if I have jsp action to servlet I can't use action ="servlet/myservlet1" I have to use
    action="HelloWorld/myservlet " if I put my servlet2 under test folder I can't call this servlet by servlet/test.servlet2, I have to use HelloWorld/servlet2,. I realize that is not glassfish problem , I just wonder is any one could give more expiration on servlet mapping ??
    Thank you !

    Depends on several factors. In which context and how exactly are you specifying the URL? In client context, the leading "/" brings you to domain root. In servlet context, the leading "/" brings you to context root. The HTML <a> element is relative to client context and JSTL <c:url> is relative to servlet context. That kind of things.

  • What's the difference between jsp and jsf?

    who can tell me what's the difference between jsp and jsf?
    I'm puzzled when I found some of the technology in jsp is so similar to the ones in jsp( javaserver page)

    Hi,
    Find the difference between JSP and JSF
    1. A developer has more control with JSP, but (should) get easier development with JSF
    2. Event handling is done differently in JSP (HTTP) and JSF (Java)
    3. The UI is designed differently (or should be at least) with JSP (markup) and JSF (components).
    4. The end product should also be defined differently - JSP page versus a JSF application.
    Is this the only thing that is need to make a decision for either or? Probably not. There are other pieces that need to be taken in account when deciding which technology to use - tools support, enough components, type of application etc.... At this point there are not enough JSF components (although there are some interesting projects underway - Ajaxfaces, Myfaces, ADF Faces, and WebChart 3d) and enterprise tools support is still limited to a few tools vendor. Looking at our ADF Faces components they are currently available as early access (not production) and demands for these components are stacking up, literally, outside my office doorstep. Although I would love to make them production - now! - it is not a viable solution since we are still checking features and fixing critical bugs.
    All this combined - not enough enterprise level components in production, lacking tools support etc... - leave customers in a vacuum where the decision is either to continue with JSP, since it is mature and has a wide developer base, or move forward with JSF not sure if the support, or the developers will be there. This is particularly sensitive to customers that need to get started now and be production by summer.
    If you are in this vacuum here are some key points promoting JSF:
    1. Fundamental unit is the Component
    2. Built in event and state management
    3. Component sets can be provided by any vendor
    4. Closer to ASP.Net or Swing development
    5. Choice of UI technology
    6. Scale up (rich clients)
    7. Scale down (mobile devices)
    8. Built into J2EE containers in J2EE 5.0 (tentative)

  • SQLJ JSP and SERVLETS which Environment?

    Hello,
    I am attempting to run the samples on Chapter 5 of the
    following documents with partial success.
    http://technet.oracle.com/docs/products/oracle8i/doc_library/817_
    doc/java.817/a83726/oraext2.htm
    http://download-west.oracle.com/otndoc/oracle9i/901_doc/java.901/
    a90208/oraext.htm#1015820
    1. Do I need the Apache+Jserv environment to run SQLJ and JSP?
    2. What do I need to do run SQLJ on oc4j if possible?
    3. I dont know how to load(?) and/or run this .sqljsp file.
    <%@ page language="sqlj"
    import="sqlj.runtime.ref.DefaultContext,oracle.sqlj.runtime.Oracl
    e" %>
    <HTML>
    <HEAD> <TITLE> The SQLJQuery JSP </TITLE> </HEAD>
    <BODY BGCOLOR="white">
    <% String empno = request.getParameter("empno");
    if (empno != null) { %>
    <H3> Employee # <%=empno %> Details: </H3>
    <%= runQuery(empno) %>
    <HR><BR>
    <% } %>
    <B>Enter an employee number:</B>
    <FORM METHOD="get">
    <INPUT TYPE="text" NAME="empno" SIZE=10>
    <INPUT TYPE="submit" VALUE="Ask Oracle");
    </FORM>
    </BODY>
    </HTML>
    <%!
    private String runQuery(String empno) throws
    java.sql.SQLException {
    DefaultContext dctx = null;
    String ename = null; double sal = 0.0; String hireDate = null;
    StringBuffer sb = new StringBuffer();
    try {
    dctx = Oracle.getConnection("jdbc:oracle:oci8:@", "scott",
    "tiger");
    #sql [dctx] {
    select ename, sal, TO_CHAR(hiredate,'DD-MON-YYYY')
    INTO :ename, :sal, :hireDate
    FROM scott.emp WHERE UPPER(empno) = UPPER(:empno)
    sb.append("<BLOCKQUOTE><BIG><B><PRE>\n");
    sb.append("Name : " + ename + "\n");
    sb.append("Salary : " + sal + "\n");
    sb.append("Date hired : " + hireDate);
    sb.append("</PRE></B></BIG></BLOCKQUOTE>");
    } catch (java.sql.SQLException e) {
    sb.append("<P> SQL error: <PRE> " + e + " </PRE> </P>\n");
    } finally {
    if (dctx!= null) dctx.close();
    return sb.toString();
    %>
    I named above file as test2.sqljsp then I tried these procedures:
    a) $ ojspc test2.sqljsp --these created all the files
    b) $ loadjava -u -v scott/tiger _test2.class -resolve
    this generated:
    initialization complete
    loading : _test2
    creating : _test2
    resolver :
    resolving: _test2
    errors : _test2
    ORA-29521: referenced name test2$_jsp_StaticText could not
    be found
    ORA-29521: referenced name test2SJProfileKeys could not be
    found loadjava: 2 errors
    c) listed the directory and both these files are there but it
    cannot resolve or find it?
    d) I recall reading something about publishjsp command but I have
    to establish a session shell with OSE? this part is very
    confusing and am not sure what to do here.
    e) not sure if i need to publish the loaded class (create a
    procedure? so it can be known to the rest of plsql?)
    A step by step procedure is very much appreciated. fyi.. I
    have Oracle 8.1.7, + oc4j, I can run sqlj from command line
    and class files generated I can run. I can also run JSP and
    servlets on the oc4j accessing the database. It is this SQLJ
    that throws me off balance. If you include Jdeveloper steps
    ro run SQLJ thats also welcome.
    Thanks in advance for kind responses posted.

    In many Model-View-Controller web applications implemented using J2EE, servlets are as controllers to direct the flow between the model and view. While servlets can output HTML code directly, it is much better to use JSPs for the most part. JSPs contain HTML and possibly Java scriptlets. The J2EE container will typically compile JSPs into servlets. While you could use a JSP as a controller, there are drawbacks to that approach. To minimize the amount of Java code in your JSPs, you can either use the tags provided by the JSP spec or use tag libraries written by someone else or yourself. See the JSTL for one such example.
    Also see:
    http://wiki.java.net/bin/preview/Javapedia/MVC
    http://wiki.java.net/bin/view/Javapedia/JavaServerPages

  • Difference between JSP and ASP

    Whatz the diff between JSP and ASP

    Hello msdnexpert,
    Active Server Pages (ASP) allows you to build rich, data driven, dynamic complex applications. ASPs are written in Perl, VBScript, C/C++. They run on machines running Microsoft Windows. With ASP, an HTML page on a web server can contain snippets of embedded code. This code is read and executed by the web server before it sends the page to the client (usually a browser such as Netscape Navigator or Microsoft's Internet Explorer.) For more information on ASP see:
    http://www.microsoft.com/workshop/server/default.asp
    or
    http://www.activeserverpages.com
    Java Server Pages (JSP) also allows you to build rich, data driven, dynamic complex applications. JSPs are written in Java. They run on any Java enabled machine, including Solarlis, Windows, Linux, and Mac OS. JSPs also makes available all of Java's industrial strength security for free. JSPs uses a syntax similar to ASP except that the scripting language is Java. Unlike ASP, JSP is an open standard implemented dozen of venders across all platforms. JSPs are closely tied to servlets because a JSP page is transformed into a servlet as part of its execution. For more information on JSP see:
    http://java.sun.com/products/jsp
    A servlet is a generic server extension -- a Java class that can be loaded dynamically to extend the functionality of a server. Servelets are commonly used with web servers, where they can take the place of CGI scripts. A servlet is similar to a proprietary server extension, except that it runs inside a Java Virtual Machine on the server side, so it is safe and portable. Servlets operate solely within the domain of the server: Unlike Applets, they do not require support for Java in the web browser.
    Unlike CGI, which must use multiple process to handle separate programs and/or separate requests, servlets can all be handled by separate threads within the same process or by threads within multiple processes spread across a number of back end servers. This means that servlets are also efficient and scalable. Because servlets run with bi-directional communication to the web server, they can interact very closely with the server to do things that are not possible with CGI. Another advantage of servlets is that they are portable: Both across operating systems and across web servers.
    Resources used in researching this response:
    Java Servlet Programing 2nd Ed by Jason Hunter with William Crawford.
    http://press.oreilly.com/jservlet2.html
    http://oreilly.com/catalog/jservlet2/
    -Merwyn,
    Developer Technical Support,
    http://www.sun.com/developers/support.

  • Communication between jsp and abstractportalcomponent

    Hello All
    Communication between jsp and abstractPortalComponent.
    jsp contains one input text field and one submit button.
    when the user clicks on submit button it will call the component and that input value will
    display in same jsp page.
    how this communication will happen?
    Rgrds
    Sri

    Hi Srikanth,
    In the JAVA File, 
    OnSubmit Event,
    String inputvalue ;
    InputField myInputField = (InputField) getComponentByName("Input_Field_ID");
    if (myInputField != null) {
                   inputvalue = myInputField.getValueAsDataType().toString();
    request.putValue("textvalue", inputvalue);
    request is IPORTALCOMPONENTREQUEST Object.
    In JSP File,   to retreive the value,
    <%
    String  textstring = (String) ComponentRequest.getValue("textvalue");
    %>
    In PORTALAPP.XML File,
    <component name="component name">
          <component-config>
            <property name="ClassName" value="classname"/>
            <property name="SafetyLevel" value="no_safety"/>
          </component-config>
          <component-profile>
            <property name="tagLib" value="/SERVICE/htmlb/taglib/htmlb.tld"/>
          </component-profile>
        </component>
    Using the code above, You can pass and read values between abstract portal component and Jsp Page.
    Instead of this, I suggest you to use JSPDYNPAGE Component for Data Exchange.
    Check the [Link|http://help.sap.com/saphelp_nw2004s/helpdata/de/ce/e0a341354ca309e10000000a155106/frameset.htm].
    Hope this helps you.
    Regards,
    Eben Joyson

  • 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

Maybe you are looking for

  • How to restrict multiple ess session and access?

    Hi experts, how to restrict multiple session for ess user? and multi access for same ess user? our problem is when user login to ess (doing session, for example leave request) and at the same time their manager is accessing travel approval task for t

  • Executing the report from the form

    I am getting the following error while executing a report from the form, and the destination format is excel RWRBE60.exe - Application Error The exception unknown software exception (0xc00000fd) occurred in the application at location 0x64aa591a. Cli

  • Incorrect value: Namespace prefix q1 of QName q1:RequestArray is undeclared

    Can someone please help me understand this error message? Incorrect value: Namespace prefix q1 of QName q1:RequestArray is undeclared Exception of class CX_SLIB I get this error when generating the Proxy Class. The URL of the Web Service WSDL is: htt

  • Where are Develop Default Settings stored for LR 5 in Win 8.1

    I want to use my Default Settings on another computer, so I need to find them and then copy them to the correct folder in the second computer. Second question. If I also happen to apply a Preset during Import that has some of the same Develops as my

  • Migrate APex workspace to new database

    Hi Can someone please help me out with the steps to migrate the Workspace from 1 database to another ? The app server remains the same, we are migrating the db to a different platform. I have Dashboard , Apex_data and flows_03100 schema created by Ap