Working of Servlets...

I have simple and very important doubt is that
When we create a servlet we will give more than one request . But the servlet will taken each request has independent .
how this possible...I am search this i cannot get a full answer...
Pls give a answer...
Regards..
Ansal M A

I'm not sure this is the right place for this question, but anyway...
Servlet must handle concurrent requests (servlets run on multithreaded servers), but each request is processed separately.
If you take a look at servlet API, you will see that each method, as a parameter receives just one request.
There is no method wich receives a bulk of request (if that's what you mean)
Regards, Cvele

Similar Messages

  • BUG: Oracle Schema Processor does not work in Servlets

    We found a bug with Oracle's Schema Processor. It does not work in Servlets.
    When we try to validate a XML document in a Servlet it does not work, but we can execute the same code in a stand alone application and it works.
    The following is the code we are using:
    try {
    File f =new File(filename);
    FileReader r = new FileReader(f);
    DOMParser dp = new DOMParser();
    URL url = createURL (filename);
    dp.setValidationMode(false);
    dp.setSchemaValidationMode(true);
    dp.setPreserveWhitespace(true);
    dp.parse(url);
    System.out.println("it is parsed");
    } catch(Exception e){System.out.println("there is Error"+e.getMessage());}
    null

    I don't think this is related to Servlets per se.
    Check that the Schema processor classes used by the servlet container, and your application are the same.
    Java does not have proper versioning of classes, I have seen many applications collapse. People compiled their code on developer machines, where it worked fine, but when moved to a production machine they failed because the production machine had a different version of classes. Usually the name of the class doesn't change, but either a method or a variable is missing in several classes. VM doesn't complain but simply crashes.
    In your Schema Processor classes that are used by the servlet engine might be different from the one that the app uses. Do a search on the file system to see how many copy of the same class bundle (zip, jar) you have on the system.

  • How file dowloading concept works using servlets.

    How file dowloading concept works using servlets.
    We will get window when downloading something from site
    if we close that window downloading stops.
    how this process works if we use servlets .
    Or what are the general concepts for downloading a file

    How file dowloading concept works using servlets.You send a request and get a reply stream. Where the servlet gets the data from is totally irrelevant.
    We will get window when downloading something from
    site
    if we close that window downloading stops.
    how this process works if we use servlets .If you close that window, downloading stops.
    Or what are the general concepts for downloading a fileSend a request, get a reply stream.

  • SQL functions ExistsNode and Extract cannot work in Servlet...

    Following lines are codes of servlet:
    package cbr;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import java.io.*;
    import oracle.xml.parser.v2.*;
    import org.xml.sax.*;
    import org.w3c.dom.*;
    import oracle.jdbc.driver.*;
    import oracle.sql.*;
    import oracle.xdb.XMLType;
    public class TestConnection extends HttpServlet
    // Use the get command to recall the servlet
    public void doGet(HttpServletRequest req,
    HttpServletResponse resp)
    throws ServletException, java.io.IOException
    // Set the content type of the response
    resp.setContentType("text/html");
    // Create a PrintWriter object
    java.io.PrintWriter out =
    new java.io.PrintWriter(resp.getOutputStream());
    // Print the HTML header option
    out.println("<html>");
    out.println("<head>");
    out.println("<title>Test Connection</title>");
    out.println("</head>");
    out.println("<h2><center>");
    out.println("Test Connection");
    out.println("</center></h2>");
    out.println("<br>");
              Connection conn = null;
              Statement s = null;
              ResultSet rset = null;
              try
                   DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
                   conn =
                        DriverManager.getConnection("jdbc:oracle:thin:@cbr.comp.polyu.edu.hk:1521:cbr", "system", "system");
                   s = conn.createStatement();
                   OraclePreparedStatement stmt;
                   String qryStr = "SELECT xmlCase FROM xmlCaseBase WHERE xmlCase.existsNode('/test/New_co_name4') = 0 AND xmlCase.extract('/test/New_co_name3/newClass/newClass_GROUP/@New_name').getStringVal() = 'football' AND problemDomainID = 'test'";
                   rset = s.executeQuery(qryStr);
    catch (Exception ex) {
    // Send the error back to the client
    out.println("Exception!");
    ex.printStackTrace(out);
    //rc = false;
    finally {
    try {
    // Always close properly
    if (rset != null) {
    rset.close();
    if (s != null) {
    s.close();
    if (conn != null) {
    conn.close();
    catch (Exception ex) {
    // Ignore any errors here
    // Close stream
    out.println("</html>");
    out.flush();
    out.close();
    public void init(ServletConfig cfg)
    throws ServletException
    super.init(cfg);
    public void destroy()
    super.destroy();
    It cannot work and has the following error message:
    Exception! java.sql.SQLException: ORA-00904: invalid column name at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java, Compiled Code) at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java, Compiled Code) at oracle.jdbc.ttc7.Oall7.receive(Oall7.java, Compiled Code) at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java, Compiled Code) at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteDescribe(TTC7Protocol.java, Compiled Code) at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java, Compiled Code) at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java, Compiled Code) at oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java, Compiled Code) at cbr.TestConnection.doGet(TestConnection.java:56) at javax.servlet.http.HttpServlet.service(HttpServlet.java, Compiled Code) at javax.servlet.http.HttpServlet.service(HttpServlet.java, Compiled Code) at org.apache.jserv.JServConnection.processRequest(JServConnection.java, Compiled Code) at org.apache.jserv.JServConnection.run(JServConnection.java, Compiled Code) at java.lang.Thread.run(Thread.java, Compiled Code)
    Would you please help me to investigate the problem and give me a solution? Thanks a lot!

    Hi,
    Just now I tried reproducing your problem on sp3/sp4/6.5, and for me it works fine.
    You can find all mappings in "<Application server>/6.0/CCS0/HTTPAPI/ServletPatternTrans" node of registry. Just make sure that your mapping entry is there, otherwise you can add it here (see the mapping of FortuneServlet for the format) and restart the iAS and web-server (plugin) after that.
    Please feel free to ask further questions.
    Sanjeev,
    Developer Support, Sun ONE Application Server-India.

  • Runtime process not working from servlet container

              Hello,
              I'm executing a standalone executable from the Runtime class, using exec.
              Process process = Runtime.getRuntime().exec(buildCommand.toString());
              There are threads monitoring the input and error streams. This same use of the Runtime
              class is used at least 5 other times in the servlet with no problems. The same method
              is also called from a JUnit test and also executes properly.
              The method called from the servlet however does not work. the executable it's calling
              is a C++ executable that uses an ODBC alias set up on the machine to connect to the
              Oracle database. For some reason the ODBC layer throws an exception while trying
              to connect when the executable is called from the servlet, rather than called from
              the command line or JUnit test.
              Does the servlet have a different environment than a client call from the JUnit test?
              Would it not have access to ODBC drivers it needs? Could there be some sort of security
              setting that the servlet container is set too low?
              Any information would be terrific.
              Thanks,
              Sara
              

    Thanks!
    I borrowed a DVD drive and everything installed correctly.

  • Cipher.getInstance("DES") not working in servlet!

    Hi - I'm working on Sun ONE Identity Server 6.1 using Sun ONE Web Server 6.1 using J2SDK 1.4.1_05
    I've modified one of the files to perform DES Encryption prior to getting some data.
    The code works fine when compiled separately - even works fine as a console program - but when I try running it as a servlet - I get a WHOLE bunch of errors when the program hits this line:
    cipher = Cipher.getInstance("DES");Here is the complete code:
    public String encryptPassword(String Password, String AppName)
         Key key;
         Cipher cipher;
         String Data = Password;
         String ApplicationName = AppName;
         String result = new String("hi");
         try
                    ObjectInputStream in = new ObjectInputStream(new FileInputStream("PrivateKey.ser"));
                  key = (Key)in.readObject();
                 in.close();
                 Security.addProvider(new com.sun.crypto.provider.SunJCE());
              cipher = Cipher.getInstance("DES"); // This LINE GIVES THE ERROR
              cipher.init(Cipher.ENCRYPT_MODE, key);
              byte[] stringBytes = Data.getBytes("UTF8");
              byte[] raw = cipher.doFinal(stringBytes);                    
              BASE64Encoder encoder = new BASE64Encoder();
              String result = encoder.encode(raw);
         catch (Exception e)
              // Print some error
    return result;
    }Here is the error log from the webserver:
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: Handler method "handleBtnSubmitRequest" threw an exception
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: java.lang.ExceptionInInitializerError
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at javax.crypto.Cipher.a(DashoA6275)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at javax.crypto.Cipher.getInstance(DashoA6275)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at com.iplanet.am.console.user.UMChangeUserPasswordViewBean.encryptPassword(UMChangeUserPasswordViewBean.java:244)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at com.iplanet.am.console.user.UMChangeUserPasswordViewBean.handleBtnSubmitRequest(UMChangeUserPasswordViewBean.java:172)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at java.lang.reflect.Method.invoke(Method.java:324)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at com.iplanet.jato.view.command.DefaultRequestHandlingCommand.execute(DefaultRequestHandlingCommand.java:183)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at com.iplanet.jato.view.RequestHandlingViewBase.handleRequest(RequestHandlingViewBase.java:299)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at com.iplanet.jato.view.ViewBeanBase.dispatchInvocation(ViewBeanBase.java:811)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at com.iplanet.jato.view.ViewBeanBase.invokeRequestHandlerInternal(ViewBeanBase.java:749)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at com.iplanet.jato.view.ViewBeanBase.invokeRequestHandler(ViewBeanBase.java:596)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at com.iplanet.jato.ApplicationServletBase.dispatchRequest(ApplicationServletBase.java:772)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at com.iplanet.jato.ApplicationServletBase.processRequest(ApplicationServletBase.java:446)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at com.iplanet.jato.ApplicationServletBase.doPost(ApplicationServletBase.java:324)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at javax.servlet.http.HttpServlet.service(HttpServlet.java:807)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at javax.servlet.http.HttpServlet.service(HttpServlet.java:908)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at org.apache.catalina.core.StandardWrapperValve.invokeServletService(StandardWrapperValve.java:771)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:322)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:212)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:209)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProcessor.java:161)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at com.iplanet.ias.web.WebContainer.service(WebContainer.java:586)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: Caused by: java.lang.SecurityException: Cannot set up certs for trusted CAs
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at javax.crypto.SunJCE_b.<clinit>(DashoA6275)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: ... 27 more
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: Caused by: java.security.PrivilegedActionException: java.security.InvalidKeyException: publicKey is not a PKCS #11 public key
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at java.security.AccessController.doPrivileged(Native Method)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: ... 28 more
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: Caused by: java.security.InvalidKeyException: publicKey is not a PKCS #11 public key 
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at org.mozilla.jss.pkcs11.PK11Signature.engineInitVerify(PK11Signature.java:172)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at org.mozilla.jss.crypto.Signature.initVerify(Signature.java:95) 
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at org.mozilla.jss.provider.Signature.engineInitVerify(Signature.java:94)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at org.mozilla.jss.provider.DSASignature.engineInitVerify(DSASignature.java:70)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at java.security.Signature.initVerify(Signature.java:297)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at sun.security.x509.X509CertImpl.verify(X509CertImpl.java:394)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at sun.security.x509.X509CertImpl.verify(X509CertImpl.java:363)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at javax.crypto.SunJCE_b.e(DashoA6275)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at javax.crypto.SunJCE_v.run(DashoA6275)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: ... 29 more
    [20/Oct/2003:16:58:01] failure ( 6417):  for host 10.42.7.235 trying to POST /amconsole/user/UMChangeUserPassword, service-j2ee reports: StandardWrapperValve[UMServlet]: WEB2792: Servlet.service() for servlet UMServlet threw exception   com.iplanet.jato.CompleteRequestException   at com.iplanet.am.console.base.ConsoleServletBase.onUncaughtException(ConsoleServletBase.java:331)   at com.iplanet.jato.ApplicationServletBase.fireUncaughtException(ApplicationServletBase.java:1023)   at com.iplanet.jato.ApplicationServletBase.processRequest(ApplicationServletBase.java:469)   at com.iplanet.jato.ApplicationServletBase.doPost(ApplicationServletBase.java:324)   at javax.servlet.http.HttpServlet.service(HttpServlet.java:807)   at javax.servlet.http.HttpServlet.service(HttpServlet.java:908)   at org.apache.catalina.core.StandardWrapperValve.invokeServletService(StandardWrapperValve.java:771)   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:322)   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:212)   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:209)   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)   at com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProcessor.java:161)   at com.iplanet.ias.web.WebContainer.service(WebContainer.java:586)    

    Hey.
    Not certain, but I think you need to make sure that your ciphers/certificates are installed on your server. Check the docs on the Sun server, and see what they say about installing certificates.
    Hope this helps.
    Vic

  • JAAS/JAZN: LDAPLoginModule doesn't work with servlet RunAs() security mode

    Just thought I'd post this here too, in case any developers actually read this list or in case someone else has run into a similar issue or has any ideas...
    I'm having a problem where whenever I use Oracle 10gAS's LDAPLoginModule at the same time as RunAs() mode OC4J crashes.
    Application is UIX/Struts for the view layer and ADF BC for the model layer. It is being developed in JDeveloper 10g (10.1.2.0.0) and deployed on 10gAS (10.1.2.0.0)
    I am using JAAS (JAZN) for authentication. I am using a custom JAAS LoginModule for the app: "oracle.security.jazn.login.module.LDAPLoginModule". Instructions for using the module are documented in the OC4J Security Guide, Chapter 9 "Configuring External LDAP
    Providers":
    http://download-east.oracle.com/docs/cd/B14099_07/web.1012/b14013/ldap3rdparty.h
    tm#sthref500
    This is working fine - I can successfully authenticate against my LDAP server.
    In order to retrieve security credentials (i.e. the Subject) while in the Model later, I am running the servlet in doAs() mode, also known as "runas-mode". This is documented in Chapter 4:
    http://download-east.oracle.com/docs/cd/B14099_07/web.1012/b14013/genconfig.htm#
    sthref322
    This works great - when I authenticate against the local XML file I can successfully run the application and retrieve the Subject and Principals.
    The problem is that whenever I try to use both of these at the same time the application will not run. I have attached a trace with JAAS/JAZN debug messages enabled.
    It appears to be failing in the process of creating the BC Application Module. Apparently when it creates a new thread to monitor the application module pool, in the process of establishing JAAS permissions for the new thread it attempts to retrieve the REALM from the oracle.security.jazn.realm.LDAPPrincipal object -- which is an unsupported function when the Principal was generated by an LDAPLoginModule. For some reason this error crashes the entire process.
    You can see a trace of my program here:
    http://www.asugroup.com/jazn-errorlog.txt
    This should be simple to reproduce by simply creating an ADF BC application, modifying orion-web.xml so that the servlet is in runas-mode, and modifying $ORACLE_HOME/j2ee/home/config/jazn-data.xml to use the LDAPLoginModule.
    All I can figure is that it must be a "bug" (or unsupported functionality) in 10gAS. WHY in the world is 10g failing on the getRealm() function of a Principal that it setup itself? Any suggestions or help would be appreciated. The only solution I can think of at this point is to throw Oracle's LoginModule implementation right out the window and write my own... although I don't even know if that will work yet.
    Jeremy

    ok, so i know that this isn't metalink... but i'm pretty sure this is either a "bug" or "unsupported feature" -- although now that i've looked a bit deeper i'm guessing it has something to do with the "role.mapping.dynamic" flag too. (Haven't tested it yet but I think it might work fine if I put the roles in the local XML file.)
    Anyway, if anyone's interested, here's detailed steps so you - YES YOU! - can reproduce the problem yourself if the desire grips you. :)
    I put this together for the TAR but figured there's some useful information in here (e.g. the debugging stuff) so it might be helpful for someone in the future to post it here too.
    1. Open or create any ADF BC project in JDeveloper. It can be ANY project as long as it uses ADF BC for the MODEL layer.
    2. Add orion-web.xml to the VIEW project if it's not already there.
    2a) Right click on orion-web.xml and select Properties
    2b) In the "JAZN" section, select the checkbox "Run as Mode"
    3. Edit web.xml to require authorization to run the app.
    3a) Right click on web.xml and select Properties
    3b) Under the "security roles" section add the name of an group you're a member of on the LDAP server. Only include the relative name of the group - not the full LDAP distinguished name. Also, convert the name to lowercase.
    3c) Under "security constraints" add a new constraint.
    3d) In the constraint, make a new resource collection called "everything" and add the URL pattern "/".
    3e) In the constraint, go to the authorization tab and select your LDAP group name.
    3f) Go to the "Login Configuration" section of web.xml and choose HTTP Basic Authentication. Leave the realm blank.
    4. Add orion-application.xml to the project if it's not already there. Configure the "JAZN" tag as follows:
    <jazn provider="XML">
    <property name="role.mapping.dynamic" value="true" />
    </jazn>
    3. Deploy the application to Oracle 10g Application Server.
    4. On the application server, edit the file $ORACLE_HOME/j2ee/home/config/jazn-data.xml
    4a) In the section jazn-data/jazn-loginconfig add a new "application" section for your application. See below for example.
    4b) Make sure the "name" of your application matches the deployment name in your EAR file for the project you deployed.
    5. I recommend enabling JAZN debugging. See below for instructions on that.
    6. Restart OC4J if you already haven't - to make sure it rereads the config, then try to run your application.
    SAMPLE JAZN-DATA.XML (CUSTOMIZE FOR YOUR LDAP SERVER)
    <jazn-data>
    <jazn-loginconfig>
    <application>
    <name>your_j2ee_deployed_application_name</name>
    <login-modules>
    <login-module>
    <class>oracle.security.jazn.login.module.LDAPLoginModule</class>
    <control-flag>required</control-flag>
    <options>
    <option>
    <name>oracle.security.jaas.ldap.provider.url</name>
    <value>ldap://10.1.1.7:389</value>
    </option>
    <option>
    <name>oracle.security.jaas.ldap.provider.user</name>
    <value>cn=stoneware,ou=stoneware,ou=okemos,ou=mi,ou=et,o=ou1</value>
    </option>
    <option>
    <name>oracle.security.jaas.ldap.provider.credential</name>
    <value>!yourpassword</value>
    </option>
    <option>
    <name>oracle.security.jaas.ldap.provider.type</name>
    <value>other</value>
    </option>
    <option>
    <name>oracle.security.jaas.ldap.user.searchbase</name>
    <value>o=ou1</value>
    </option>
    <option>
    <name>oracle.security.jaas.ldap.user.searchscope</name>
    <value>subtree</value>
    </option>
    <option>
    <name>oracle.security.jaas.ldap.user.name.attribute</name>
    <value>cn</value>
    </option>
    <option>
    <name>oracle.security.jaas.ldap.user.object.class</name>
    <value>inetOrgPerson</value>
    </option>
    <option>
    <name>oracle.security.jaas.ldap.role.searchbase</name>
    <value>o=ou1</value>
    </option>
    <option>
    <name>oracle.security.jaas.ldap.role.searchscope</name>
    <value>subtree</value>
    </option>
    <option>
    <name>oracle.security.jaas.ldap.role.name.attribute</name>
    <value>cn</value>
    </option>
    <option>
    <name>oracle.security.jaas.ldap.role.object.class</name>
    <value>groupOfNames</value>
    </option>
    <option>
    <name>oracle.security.jaas.ldap.membership.searchscope</name>
    <value>direct</value>
    </option>
    <option>
    <name>oracle.security.jaas.ldap.member.attribute</name>
    <value>member</value>
    </option>
    </options>
    </login-module>
    </login-modules>
    </application>
    </jazn-loginconfig>
    </jazn-data>
    for Sun Java System Application Server and Microsoft Active Directory examples see:
    http://download-east.oracle.com/docs/cd/B14099_07/web.1012/b14013/ldap3rdparty.htm#sthref500
    ENABLING JAZN DEBUGGING MESSAGES ON ORACLE 10G APPLICATION SERVER
    1. Login to Enterprise Manager 10g Application Server Control
    2. If you are part of a farm you will get a list of instances. Select the instance your app is deployed on.
    3. In the "System Components" section of the home page, click on your OC4J instance (default name is "home").
    4. In the OC4J home, click on the "Administration" tab.
    5. Select "Server Properties" from the Instance Properties section.
    6. In the Command Line Options section, there is an option called "Java Options".
    7. At the end of the "Java Options", append the text "-Djazn.debug.log.enable=true"
    8. When prompted, restart the OC4J instance.
    Debug information is captured by OPMN and stored in a log file. The log file can be found in the directory $ORACLE_HOME/opmn/logs
    The default name (if your instance name is "home") is "OC4J~home~default_island~1"

  • How internally session works in servlet

    hi 2 all,
    My college project is simulate a Httpserver which handles request and response similar to that of Apache Tomcat.
    i want to know how session internally works. work in the sense, wt have they(Apache Tomcat) did in their HttpSession class. how and in what way the session must be maintained if i code that class of my own.
    Thaks in advance ..

    Apache Tomcat is open source so you can dowload the source and look at any classes you want. If you go to the following link:
    http://tomcat.apache.org/download-55.cgi
    and scroll down the page, you'll see links for the source code in either a tar or zip format.
    By the way, Apache Tomcat is an application server not an HttpServer. Apache also has an HttpServer. Application servers support servlets whereas HttpServers do not (they can server static content natively and dynamic content via CGI programs). HttpServers process requests and server up responses but they have no notion of a session (the http protocol is stateless). The reason I am mentioning all this is to warn you that your professor might not be thinking of the Apache Tomcat model. He might be thinking of the Apache HttpServer model. Make sure you're going down the right path before wasting any effort.

  • Run-as does not work for servlets

    When a servlet is marked with a run-as role, other servlets in the same web app without run-as role will not propagate the caller principal correctly to EJBs.
    Is any configuration required except setting the run-as principal in sun-web.xml?

    Coming back one year later, this bug is still present, even in Update 1. Here is a little application that should show the problem:
    /*----------------------------- Test.java ------------------------------------*/
    package sunastest;
    import java.rmi.RemoteException;
    import javax.ejb.EJBObject;
    public interface Test extends EJBObject {
        String getPrincipal() throws RemoteException;
    /*----------------------------- TestHome.java --------------------------------*/
    package sunastest;
    import java.rmi.RemoteException;
    import javax.ejb.CreateException;
    import javax.ejb.EJBHome;
    public interface TestHome extends EJBHome {
        Test create() throws CreateException, RemoteException;
    /*----------------------------- TestEJB.java ---------------------------------*/
    package sunastest;
    import javax.ejb.SessionBean;
    import javax.ejb.SessionContext;
    public class TestEJB implements SessionBean {
        private SessionContext sessionContext = null;
        public void setSessionContext(SessionContext sessionContext) {
            this.sessionContext = sessionContext;
        public void ejbCreate() {
        public void ejbRemove() {
        public void ejbActivate() {
        public void ejbPassivate() {
        public String getPrincipal() {
            return sessionContext.getCallerPrincipal().getName();
    /*----------------------------- TestServlet.java -----------------------------*/
    package sunastest;
    import java.io.IOException;
    import java.io.PrintWriter;
    import java.rmi.RemoteException;
    import javax.ejb.CreateException;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import javax.rmi.PortableRemoteObject;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class TestServlet extends HttpServlet {
        protected void doGet(
            HttpServletRequest request,
            HttpServletResponse response)
            throws ServletException, IOException {
            String p = null;
            try {
                Context jndiContext = new InitialContext();
                try {
                    TestHome home =
                        (TestHome) PortableRemoteObject.narrow(
                            jndiContext.lookup("java:comp/env/ejb/Test"),
                            TestHome.class);
                    Test test = home.create();
                    p = test.getPrincipal();
                } catch (RemoteException e) {
                    jndiContext.close();
                } catch (CreateException e) {
                    jndiContext.close();
                } finally {
                    jndiContext.close();
            } catch (NamingException e) {
                throw new ServletException(e);
            PrintWriter out = response.getWriter();
            out.println("principal in EJB: " + p);
    <!--=========================================================================-->
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE application PUBLIC
             '-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN'
             'http://java.sun.com/dtd/application_1_3.dtd'>
    <application>
        <display-name>app_test_ear</display-name>
        <description>Application description</description>
        <module>
            <ejb>ejb.jar</ejb>
        </module>
        <module>
            <web>
                <web-uri>web.war</web-uri>
                <context-root>test</context-root>
            </web>
        </module>
        <security-role>
            <role-name>RunAsRole</role-name>
        </security-role>
    </application>
    <!--=========================================================================-->
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE sun-application PUBLIC
            '-//Sun Microsystems, Inc.//DTD Sun ONE Application Server 7.0 J2EE Application 1.3//EN'
            'http://www.sun.com/software/sunone/appserver/dtds/sun-application_1_3-0.dtd'>
    <sun-application>
        <!-- create these users in the server -->
        <security-role-mapping>
             <role-name>User</role-name>
             <principal-name>user</principal-name>
        </security-role-mapping>
        <security-role-mapping>
             <role-name>RunAsRole</role-name>
             <principal-name>runasuser</principal-name>
        </security-role-mapping>
    </sun-application>
    <!--=========================================================================-->
    <?xml version="1.0"?>
    <!DOCTYPE ejb-jar PUBLIC
            "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
            "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
    <ejb-jar>
        <enterprise-beans>
            <session>
                <ejb-name>Test</ejb-name>
                <home>sunastest.TestHome</home>
                <remote>sunastest.Test</remote>
                <ejb-class>sunastest.TestEJB</ejb-class>
                <session-type>Stateless</session-type>
                <transaction-type>Container</transaction-type>
            </session>
        </enterprise-beans>
        <assembly-descriptor>
            <method-permission>
              <unchecked />
              <method>
                <ejb-name>Test</ejb-name>
                <method-name>*</method-name>
              </method>
            </method-permission>
            <container-transaction>
              <method>
                <ejb-name>Test</ejb-name>
                <method-name>*</method-name>
              </method>
              <trans-attribute>NotSupported</trans-attribute>
            </container-transaction>
        </assembly-descriptor>
    </ejb-jar>
    <!--=========================================================================-->
    <?xml version="1.0"?>
    <!DOCTYPE sun-ejb-jar PUBLIC
            '-//Sun Microsystems, Inc.//DTD Sun ONE Application Server 7.0 EJB 2.0//EN'
            'http://www.sun.com/software/sunone/appserver/dtds/sun-ejb-jar_2_0-0.dtd'>
    <sun-ejb-jar>
        <enterprise-beans>
            <ejb>
                <ejb-name>Test</ejb-name>
                <jndi-name>test/Test</jndi-name>
                <bean-pool/>
            </ejb>
        </enterprise-beans>
    </sun-ejb-jar>
    <!--=========================================================================-->
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE web-app PUBLIC '-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN' 'http://java.sun.com/dtd/web-app_2_3.dtd'>
    <web-app>
        <servlet>
            <servlet-name>TestServlet</servlet-name>
            <servlet-class>sunastest.TestServlet</servlet-class>
        </servlet>
        <servlet>
            <servlet-name>RunAsTestServlet</servlet-name>
            <servlet-class>sunastest.TestServlet</servlet-class>
            <!-- only one servlet specifies run-as -->
            <run-as>
                <role-name>RunAsRole</role-name>
            </run-as>
            <!-- -->
        </servlet>
        <servlet-mapping>
            <servlet-name>TestServlet</servlet-name>
            <!-- call this, it will also run-as -->
            <url-pattern>/test</url-pattern>
        </servlet-mapping>
        <servlet-mapping>
            <servlet-name>RunAsTestServlet</servlet-name>
            <url-pattern>/run-as</url-pattern>
        </servlet-mapping>
        <security-constraint>
            <web-resource-collection>
                <web-resource-name>test</web-resource-name>
                <url-pattern>/*</url-pattern>
                <http-method>GET</http-method>
                <http-method>POST</http-method>
            </web-resource-collection>
            <auth-constraint>
                <role-name>User</role-name>
            </auth-constraint>
        </security-constraint>
        <login-config>
            <auth-method>BASIC</auth-method>
            <realm-name>test</realm-name>
        </login-config>
        <ejb-ref>
            <ejb-ref-name>ejb/Test</ejb-ref-name>
            <ejb-ref-type>Session</ejb-ref-type>
            <home>sunastest.TestHome</home>
            <remote>sunastest.Test</remote>
            <ejb-link>ejb.jar#Test</ejb-link>
        </ejb-ref>
    </web-app>
    <!--=========================================================================-->
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE sun-application-client PUBLIC
            '-//Sun Microsystems, Inc.//DTD Sun ONE Application Server 7.0 Application Client 1.3//EN'
            'http://www.sun.com/software/sunone/appserver/dtds/sun-application-client_1_3-0.dtd'>
    <sun-web-app>
        <servlet>
            <servlet-name>RunAsTestServlet</servlet-name>
            <principal-name>runasuser</principal-name>
        </servlet>
    </sun-web-app>
    <!--=========================================================================-->

  • Why can't dispatcher work in servlet?

    I want to dispatche a page in servlet,but there is nothing.
    Code:
    RequestDispatcher dispatcher=
    getServletContex().getRequestDispatcher ("http://localhost:8080/HotelReservation/login.jsp");
    dispatcher.forward(request,response);

    Hello,
    the pathname must begin with a "/" and is interpreted as relative to the current context root.
    Change RequestDispatcher dispatcher= getServletContex().getRequestDispatcher("http://localhost:8080/HotelReservation/login.jsp"); If your context is "HotelReservation" to: RequestDispatcher dispatcher= getServletContex().getRequestDispatcher("/login.jsp"); Or, if your context is "/", to: RequestDispatcher dispatcher= getServletContex().getRequestDispatcher("/HotelReservation/login.jsp"); Also, if the page you dispath to, isn't in the same context of the caller page you have to use ServletContext.getContext("context name").getRequestDispatcher(...)

  • Set content type on header doesn't work on servlet filter

    I am trying the following filter:
    chain.doFilter(req, responseWrapper);
    and im trying to set the content type:
    response.SetHeader("Content-Type","text/plain");
    But it doesn't seem to set it.
    I have the wrapper as:
    private ByteArrayOutputStream     output;
         private int                              contentLength;
         private String                         contentType;
         private CharArrayWriter               myOut;
         private int                              mode;
         public JPServletResponseWrapper(HttpServletResponse response) {
              super(response);
              output = new ByteArrayOutputStream();
              this.myOut = new CharArrayWriter();
         public ServletOutputStream getOutputStream() throws IOException {
              this.setMode(2);
              return new JPServletOutputStream(output);
         public PrintWriter getWriter() throws IOException {
              this.setMode(1);
              return new PrintWriter(this.myOut);
         public byte[] getData() {
              return output.toByteArray();
         public int getContentLenght() {
              return this.contentLength;
         public void setContentLength(int len) {
              this.contentLength = len;
              super.setContentLength(len);
         public String getContentType() {
              return this.contentType;
         public void setContentType(String type) {
              this.contentType = type;
              super.setContentType(type);
         public int getMode() {
              return mode;
         public void setMode(int mode) {
              this.mode = mode;
         public String toString() {
              return myOut.toString();
    The page is being displayed as text/html and not as text/plain.
    Is there any reason?

    Hello,
    I think RowOrdinal is the problem. You can try below suggestion:
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/634b3f24-b009-415d-8b45-40c11105b803/bug-in-creating-more-columns-in-sharepoint-list-filters?forum=sharepointdevelopmentlegacy
    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • Problem with displaying BLOB images on JSP page using a servlet

    hi. I have a big problem with displaying BLOB images using JSP. I have a servlet that connects to the oracle database, gets a BLOB image , reads it, and then displays it using a BinaryStream. The problem is , this works only when i directly call that servlet, that is http://localhost:8080/ImageServlet. It doesn't work when i try to use that servlet to display my image on my JSP page (my JSP page displays only a broken-image icon ) I tried several coding approaches with my servlet (used both Blob and BLOB objects), and they work just fine as long as i display images explicitly using only the servlet.
    Here's what i use : ORACLE 10g XE , Eclipse 3.1.2, Tomcat 5.5.16 , JDK 1.5
    here is one of my image servlet's working versions (the essential part of it) :
                   BLOB blob=null;
              rset=st.executeQuery("SELECT * FROM IMAGES WHERE ID=1");
              while (rset.next())
                   blob=((OracleResultSet)rset).getBLOB(2);
              response.reset();
              response.setContentType("image/jpeg");
              response.addHeader("Content-Disposition","filename=42.jpeg");
                    ServletOutputStream ostr=response.getOutputStream();
                   InputStream istr=blob.getBinaryStream(1L);
                    int size=blob.getBufferSize();
              int len=-1;
                    byte[] buff = new byte[size];
                         while ((len=istr.read( buff ))!=-1 ) {
                   ostr.write(buff,0,len);
             response.flushBuffer();
             ostr.close(); and my JSP page code :
    <img src="/ImageServlet" border="0"  > If you could just tell me what i'm doing wrong here , or if you could show me your own solutions to that problem , i would be very greatful ,cos i'm realy stuck here , and i'm rather pressed for time too. Hope someone can help.

    I turns out that it wasn't that big of a problem after all. All i had to do was to take the above code and place it into another JSP page instead of into a servlet like i did before. Then i just used that page as a source for my IMG tag in my first JSP. It works perfectly well. Why this doesn't work for servlets i still don't know, but it's not a problem form me anymore . Ofcourse if someone knows the answer , go ahead and write. I would still appriceatte it.
    here's the magic tag : <img src="ImageJSP.jsp" border="0"  > enjoy : )

  • How to create a simple web.xml for using servlets

    Hello i wanna configure the web.xml that i can use sevlets and beans, but how can i do that?
    This is de directorie i have installed my webapp
    C:\Tomcat 4.1\webapps\testapp
    C:\Tomcat 4.1\webapps\test\WEB-INF\classes (in this dir, I wanna put my beans and servlets, I got one servlet and the name is LogIn.class).
    And i wanna request my servlets with the url http://localhost:8080/testapp/servlet/LogIn
    How can i create a very basic web.xml with working beans, servlets and session? It is for testing-use only, so the security is not important for me at this moment.
    Tnx

    under your web-inf
    in your web.xml file you must map
    the servlets
    under the <web-app> tag type
    <servlet>
         <servlet-name>LogIn</servlet-name>
         <servlet-class>com.LogIn</servlet-class>
    </servlet>
    <servlet-mapping>
          <servlet-name>LogIn</servlet-name>
          <url-pattern>/LogIn</url-pattern>
    </servlet-mapping>ps: start using some IDE such as NetBeans or Ecclipse
    since they will take care of mapping all servlets and Beans
    and generate all the necessary files for your web-app

  • Tomcat 5.5, struts, AJAX - Works on localhost but not on online web-server

    Hello,
    I'm trying to add some functionality from Ajax to my client's web application. And I'm stuck on this problem for the past 4 days now.
    To make a long story short, the application works perfectly on my localhost, but once I deploy it to the online server it pops a Page Not Found message (written in the JavaScript of Ajax engine). Though I have worked with servlets and struts a bit, I still consider myself very new.
    Here are some specifications:
    - The jar files are in tomcat-5.5/common/lib
    - The servlets (compiled correctly) are in webapps/ROOT/WEB-INF/classes/javaClasses
    - My web.xml and struts-config.xml are in WEB-INF, both of which I believe are configured correctly:
    web.xml
    =======
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
    <web-app>
         <servlet>
              <servlet-name>action</servlet-name>
              <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
              <init-param>
              <param-name>config</param-name>
              <param-value>/WEB-INF/struts-config.xml</param-value>
              </init-param>
         </servlet>
         <servlet-mapping>
              <servlet-name>action</servlet-name>
              <url-pattern>*.do</url-pattern>
         </servlet-mapping>
         <welcome-file-list>
              <welcome-file>/index.jsp</welcome-file>
         </welcome-file-list>
    </web-app>
    struts-config.xml
    ==============
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
    <struts-config>
    <action-mappings>
    <action path="/signup" type="org.apache.struts.actions.ForwardAction" parameter="/signup.jsp" />
    <action path="/countries" type="javaClasses.GetCountries" />
    </action-mappings>
    </struts-config>
    I noticed when I type "countries.do" on my localhost, the action is processed perfectly, however on the online server, it displays me the 404 error page.
    I thought it wasn't seeing the struts-config.xml so I played around with the directory path struts-config.xml and replaced it with:
    <param-value>/home/shaghig/webapps/ROOT/WEB-INF/struts-config.xml</param-value>
    but still no luck.
    What is it that I am not doing right? Any input or guidance would be very much appreciated.

    Have you resolved your problem? I am running into the SAME EXACT issues with my application. The only difference is I'm not deploying to webapps/ROOT/; I'm deploying to my own directory based on my WAR file name (webapps/<web_application_name>/WEB-INF....blah blah). If you figured out your problem (believe me, I wish I could be of some help) I would LOVE to hear what you did/figured out.
    -C

  • Value="${bean.param}" doesn't work on tomcat 5, WHY ?

    Hello,
    I have a web application with jsf 1.1. My application has to play some flash movies. Here is my playMovie.jsp :
    <h:form id="form"  onkeydown="return sendInfo(event);">
           <h:commandButton id="redirect" action="#{marketTest.whichSessionAction}" style="visibility:hidden;"/>
           <h:outputLabel id="videoName" value="#{marketTest.videoName}" style="visibility:hidden;"/>
           <f:verbatim>
              <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
                      codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0"
                      width="800" height="600" id="market" align="middle">
                  <param name="allowFullScreen" value="false" />
                  <param name="movie" value="${marketTest.videoName}" />
                  <param name="menu" value="false" />
                  <param name="quality" value="high" />
                  <param name="bgcolor" value="#000000" />
                  <param name="loop" value="false" />
                  <embed src="${marketTest.videoName}" menu="false" quality="high" bgcolor="#000000" width="800" height="600" name="market" align="middle"
                         loop="false" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"/>
             </object>
             <br/>
           </f:verbatim>
            <h:outputText value="#{marketTest.userPosText}"/>
         </h:form>I test it on my computer where I have tomcat 6 and it works very well, but when I put the application on the server where is installed tomcat 5, I have no movies and when I looked at the source page I saw that ${marketTest.videoName} wasn't translated to the real movie name.
    Does someone know what can I do ?
    Thanks in advance.

    EL in template text only works on Servlet 2.4 / JSP 2.0 and newer. So you need at least Tomcat 5.5. Tomcat 5.0 is Servlet 2.3 / JSP 1.2 and Tomcat 6.0 is Servlet 2.5 / JSP 2.1.
    To fix this, use JSTL c:out tag. This problem is by the way not related to JSF.

Maybe you are looking for