Principle of servlets

Hi,
I'm trying to learn how to use servlets, and it's quite difficult. I think I don't understand the principle of servlets.
Aren't there a server and a client, which has a query button? When the client pushes the button and sends the request, doesn't he send it to the server, which uses some of its data and sends the answer back to the client?
I saw some tutorials on the web, but when is the connection to the server? Isn't there any IP adress, or something? I mean, with the method init(), the client knows where the server is? And how do we use methods from the server? How do we treat the data sent by the client?
There's something I don't get, so if someone could explain me in a few lines the principles of servlets and the way to use them, it would be great.
Thanks

When the client pushes the button and sends
the request, doesn't he send it to the server, which
uses some of its data and sends the answer back to the
client?Seek documentation on "Http Request/Response Model"
I saw some tutorials on the web, but when is the
connection to the server? Isn't there any IP adress,
or something? I mean, with the method init(), the
client knows where the server is? And how do we use
methods from the server? How do we treat the data sent
by the client?The methods in the Servlet ARE NOT called by you, they are done automagically. The init() is called on startup, and doGet() and doPost() are called when you submit. To learn more, read up on "HTML forms" and "Form Submit Action".
Also, data is sent up to the server via the Request object.
>
There's something I don't get, so if someone could
explain me in a few lines the principles of servlets
and the way to use them, it would be great.
Thanks By the way, Servlets are EXTREMELY easy, not complex. It sounds to me that you just need to go grab a book, entry-level, and spend some time on fundamentals. Perhaps the J2EE tutorial? First 5 pages of that tutorial will cover everything you asked.

Similar Messages

  • Help on "java.lang.NoClassDefFoundError: oracle/jsp/runtimev2/JspReportUtil"

    Hi all,
    I encounted the following exception on a deployed project to ias 9.0.2:
    500 Internal Server Error
    java.lang.NoClassDefFoundError: oracle/jsp/runtimev2/JspReportUtil     at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:333)     at javax.servlet.http.HttpServlet.service(HttpServlet.java:336)     at com.evermind[Oracle9iAS (9.0.2.0.0) Containers for J2EE].server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java(Compiled Code))     at oracle.security.jazn.oc4j.JAZNFilter.doFilter(JAZNFilter.java(Compiled Code))     at com.evermind[Oracle9iAS (9.0.2.0.0) Containers for J2EE].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java(Compiled Code))     at com.evermind[Oracle9iAS (9.0.2.0.0) Containers for J2EE].server.http.ServletRequestDispatcher.include(ServletRequestDispatcher.java:108)     at com.evermind[Oracle9iAS (9.0.2.0.0) Containers for J2EE].server.http.EvermindPageContext.handlePageThrowable(EvermindPageContext.java:596)     at com.evermind[Oracle9iAS (9.0.2.0.0) Containers for J2EE].server.http.EvermindPageContext.handlePageException(EvermindPageContext.java:567)     at data.lookjjview._jspService(_lookjjview.java(Compiled Code))     at com.orionserver[Oracle9iAS (9.0.2.0.0) Containers for J2EE].http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)     at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:302)     at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:407)     at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:330)     at javax.servlet.http.HttpServlet.service(HttpServlet.java:336)     at com.evermind[Oracle9iAS (9.0.2.0.0) Containers for J2EE].server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java(Compiled Code))     at oracle.security.jazn.oc4j.JAZNFilter.doFilter(JAZNFilter.java(Compiled Code))     at com.evermind[Oracle9iAS (9.0.2.0.0) Containers for J2EE].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java(Compiled Code))     at com.evermind[Oracle9iAS (9.0.2.0.0) Containers for J2EE].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java(Compiled Code))     at com.evermind[Oracle9iAS (9.0.2.0.0) Containers for J2EE].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java(Compiled Code))     at com.evermind[Oracle9iAS (9.0.2.0.0) Containers for J2EE].server.http.AJPRequestHandler.run(AJPRequestHandler.java:151)     at com.evermind[Oracle9iAS (9.0.2.0.0) Containers for J2EE].util.ThreadPoolThread.run(ThreadPoolThread.java(Compiled Code))
    I found there is leak of memory resource on the Oracle RDBMS host while this problem occurs,the database host has only 512Mb RAM.And I once configred the database to worked on Shared Mode,in this case the database has less chance of memory leak,but the above exception occurs more often.So I have to change the database to work back on Dedicate Mode!It's hard to find any tips on my Exception as mentioned above.
    And I want to know the working principle of servlet on iAS.When invoke a servlet,will the servlet be cached on Memory from the first request,or it will be clear up and re-inload until next request?I just wonder if the iAS server will run out of memory,because I noticed there is a memory configure option in "jser.properties" file.And the exception I encoutered seems to occur at a critical point.

    Thanks but that did help since they are talking about
    JDK1.3. I downloaded J2SDK-Beta 3 it says that you
    don't need to set a class path variable. You need to be careful about how you interpret this statement. The rule is, if your system doesn't have a classpath set, you'll get a default of the current directory (.). If your system does have a classpath setting, then the setting will be used.
    Just because you didn't set your classpath doesn't mean someone or some other application didn't. Make sure that your system doesn't have a classpath setting. If it does, you may need to add the current directory (.) to it.

  • How can the servlet engine create objects of interfaces?help

    hello,
    I have this basic fundamental query...when using servlets i noticed that so many methods in the HttpServlet class take as arguments objects of the type "Interface"..where as basic principle in java is u cant instantiate interfaces...interfaces r mere templates which u implement by ur own custom classes.
    For example the doGet method recieves from the servlet engine(servlet container) two arguments which r HttpServletResponse object and HttpServletRequest object..and u use these further to make use of the methods of the inmterfaces..which again is a mystery to me...why?
    here is why:-
    since HttpServletResponse and HttpServletRequest r interfaces..they cant be instantiated...and now that the sevlet engine provides objects of these interfaces...how come u r able to to use the methods of these interfaces...for r they not empty methods?..
    example how r u able to make the sendRedirect() method of HttpServletResponse interface work...is this method not an empty method?
    there r several interfaces...whose objects r being used and passed in this similar fashion....(for example there r many methods that return an enumeration...which is used as if it were an ordinary class that can be instantiated..and whose methods r non empty emthods)
    please help me resolve this mystery
    sheeba

    Don't call me "u". The word is "you". Likewise "are" and not "r".
    The servlet engine creates objects of concrete classes that implement those interfaces. If you want to find the names of those classes in your particular server, you could use for examplereq.getClass().getName()

  • Setting principle in request object

    hi
    i came to know that i need to keep the principle object in request object to
    make the configured role availble to be acessible by web container to map with the roles provided in the web.xml
    could any body help me letting knwo how cani keep the principle object to session..?
    i tried this
    it is giving null
         if (null != req.getUserPrincipal())
                   System.our.println("Role is "
                             + req.getUserPrincipal().getName());
              else
                   System.out.println("User Principle is null");Thanks in advance

    1) You need to take this question to the Servlet forum; the Cryptography forum is not the right place for this question.
    2) Read the Servlet Specification; it explains the use of Roles, Principals (note the spelling) within HTTP requests and sessions and provides examples of how to do this.

  • Concurreny in Servlets/JSP

    Hi I have a JSP which presents data to a user in the form of a list. Basic CRUD operations can be performed on this data. At the moment I have a JSP, which talks to a servlet, this servlet then uses another class to actually perform the operations. This 'helper' class has several static methods defined in it.
    JSP --> Servlet --> helper Class
    I am wondering what happens if there are multiple users using the jsp and performing different operations. How is this handled in the servlet and the helper class, can multiple users use the servlet at the same time?
    If there is some documentation that is available that I could read that would be great!
    Here are parts of my servlet and helper class (The suffix bean is slightly misleading, it is just an ordinary java class)
    // Servlet code
         public void processContactRequests(HttpServletRequest request)
              // Create the model
              String operation = request.getParameter("operation");
              ContactModel contact = new ContactModel();          
              contact.setFirstName(request.getParameter("firstName"));
              contact.setLastName(request.getParameter("lastName"));
              contact.setPhoneNumber(request.getParameter("phoneNumber"));
              contact.setDetails(request.getParameter("details"));
              contact.setGender(request.getParameter("gender"));
              contact.setDateOfBirth(StringUtil.getDate(request.getParameter("dateOfBirth"), StringUtil.DATE_FORMAT_SHORT));
              contact.setMaritalStatus(request.getParameter("maritalStatus"));
              contact.setAddress1(request.getParameter("address1"));
              contact.setAddress2(request.getParameter("address2"));
              contact.setAddress3(request.getParameter("address3"));
              contact.setAddress4(request.getParameter("address4"));
              contact.setUserDefinable1(request.getParameter("userDefinable1"));
              contact.setUserDefinable2(request.getParameter("userDefinable1"));
              contact.setUserId(request.getParameter("userId"));
              contact.setPrimaryKey(Integer.parseInt(request.getParameter("primaryKey")));
              if(!StringUtil.isEmpty(operation) && operation.equals("update")) {
                   System.out.println("\n\n\nUpdating...");
                   ContactBean.updateModel(contact);     
              else if(!StringUtil.isEmpty(operation) && operation.equals("insert")) {
                   System.out.println("\n\n\nAdding....");                    
                   ContactBean.addModel(contact);     
              else if(!StringUtil.isEmpty(operation) && operation.equals("delete")) {
                   System.out.println("\n\n\nRemoving....");
                   ContactBean.removeModel(contact);     
    // Static method in my helper class
    public static void updateModel(ContactModel contact) {
    System.out.println("Inside Update Contact Method...");
    Connection conn = null;
    PreparedStatement statement = null;
    ResultSet rs = null;
         try {
    // get a connection to the database
    conn = Database.getConnection();
         String sql = "UPDATE contacts SET first_name = ?, " +
                   "last_name = ?, phone = ?, details = ?, user_id = ?, " +
                   "date_of_birth = ?, gender = ?, martial_status = ?, address_1 = ?, " +
                   "address_2 = ?, address_3 = ?, address_4 = ?, user_definable_1 = ?, " +
                   "user_definable_2 = ? " +
                   "WHERE contact_primary_key = ? " +
                        "AND user_id = ?";      
    statement = conn.prepareStatement(sql);
    statement.setString(1, contact.getFirstName());
    statement.setString(2, contact.getLastName() );
    statement.setString(3, contact.getPhoneNumber());
    statement.setString(4, contact.getDetails());
    statement.setString(5, contact.getUserId());
    statement.setTimestamp(6, contact.getDateOfBirth());
    statement.setString(7, contact.getGender() );
    statement.setString(8, contact.getMaritalStatus() );
    statement.setString(9, contact.getAddress1() );
    statement.setString(10, contact.getAddress2() );
    statement.setString(11, contact.getAddress3() );
    statement.setString(12, contact.getAddress4() );
    statement.setString(13, contact.getUserDefinable1());
    statement.setString(14, contact.getUserDefinable2());      
    statement.setInt(15, contact.getPrimaryKey());      
    statement.setString(16, contact.getUserId());      
         int iSuccess = statement.executeUpdate();
    if (iSuccess == 0)
    //throw a EJB exception here
         System.out.println("Error getting database data: ");
    } catch (SQLException e){
         e.printStackTrace();
         System.out.println("Error in Update Contact Method: " + e);
    } finally
    Database.close(conn, statement);

    concurrency in java has produced research papers. i
    took a course on this; but am still not really
    comfortable doing concurrency code in java; because
    the design of JVM does not directly imply that if you
    use synchronized() method, your methods will be really
    synchronized.I'm quite sure that this not is correct.
    <snip>
    your example scenarios can be: for example, do 2 or
    more threads need to come and meet at this atomic
    action? do they need to exchange message when they are
    inside the synchronized area? and do they need to
    leave a synchronized area at the same time? Another
    scenario is simple multiplereaders_singlewriter
    problem.I'm not sure how these comments make sense. Exchange messages? The threads can't both be inside the synchronized area at the same time anyway. It's the definition of synchronized in Java that precludes this possibility. If you want to get off into discussions of synchronization and atomic code and low level implementation details, that's one thing, but it's not really relavent to the OP's question. The answer to which is what I already said above.
    Implementations can include semaphores and monitors.
    These are some books:
    G.R. Andrews, Concurrent Programming: Principles and
    Practice, Benjamin/Cummings, 1991.
    R.A. Olsson and A.W. Keen, The JR Programming
    Language: Concurrent Programming in an Extended Java,
    (draft).
    I am not sure if I just gave you an over-dozage. But,
    this is a very interesting topic. :)Yes, it is... But not here.

  • How choose between post and get when calling a servlet from a java class ??

    Hi !!
    I have an urgent question : in fact some java programs that call servlets are published on the web, and the principle is to make an url.openconnection() to reach the servlet.
    What I don't understand is how we choose if we want to call the get or the post method on the servlet ?????
    please answer very fast.....
    thanks...

    from the URL documentation of openConnection():
    "If for the URL's protocol (such as HTTP or JAR), there exists a public, specialized URLConnection subclass belonging to one of the following packages or one of their subpackages: java.lang, java.io, java.util, java.net, the connection returned will be of that subclass. For example, for HTTP an HttpURLConnection will be returned, and for JAR a JarURLConnection will be returned."
    Obviously, in case of a http servlet, normally an instance of HttpURLConnection will be returned. If you don't change the request method, GET is the default.

  • Can I execute four servlets in succession using rd.forward

    Hi^^,
    I have created 1 JSP and four servlets which are as follows:
    Login.jsp
    SessionLogin.java
    Authenticate.java
    Authorize.java
    Bologin.java
    The Login.jsp transfers the control to SessionLogin.java which transfers the control to Authenticate.java which then transfers the control to Authorize.java which then transfers the control to Bologin.java. I do this using the RequestDispatcher code. My query is that is it technically correct to do this or I am violating ther MVC principle.
    thanks

    Hi,
    fyi, my project is part of a larger project which is based on MVC architecture. I just need to follow the flow and code the servlets so that they are executed in the right sequence. However thanks for your suggestions, i do value them.
    Regards,
    Prashant

  • Servlet and performance

    I have built a servlet (actually two) who listen on two ports. One is responsible to catch queries from web anoher is responsible for catching queries from LAN. There are two NIC (network interface cars) inside the server with each their own subnet.
    It seems the server has performance issues. Can a servlet have this effect? I used the principle of the DaemonHttpServlet (url: http://www.porcupyne.org/docs/browse_source/JavaServlet/com/oreilly/servlet/DaemonHttpServlet.java.html)
    I have built a server in my own network and i have no problems. Even with two NIC's. If i place the server in another LAN there seems to be performance problems..
    Anyone a suggestion?

    It seems the server has performance issues. Can a
    servlet have this effect? Yes and no. I want to say no. Truth is, any part of the app could be causing performance issues. If you write poor performing code it will perform poorly, whether it's in a servlet or wherever.
    I used the principle of the
    DaemonHttpServlet (url:
    http://www.porcupyne.org/docs/browse_source/JavaServle
    t/com/oreilly/servlet/DaemonHttpServlet.java.html)
    I have built a server in my own network and i have no
    problems. Even with two NIC's. If i place the server
    in another LAN there seems to be performance
    problems..
    Anyone a suggestion?Sounds like you could have some network issues. No way to know without troubleshooting it or you'd have to provide some real specific information.

  • Can Servlet remember the history ?

    I implemented a servlet that searches the web for the book information and
    display the search result to the user. The problem is, there might be thousands
    of books (a sample book record is shown bellow) and users can not read all the information. So I was thinking of generating a summary page for the records with a link to the detailed information for each record. But once the servlet returns the result, all the search result in memory will be flushed. I'm wondering if there is any way to accomplish this?
    My current solution is to embed java script in the returned result to hide some of the
    book information. Can anybody give some suggestions?
    Record Type: Book
    Author: Clark, William E., 1914-
    Title: Fire fighting, principles & practices, 1974
    Subject: Firefighting operations
    Publisher: Dun Donnelley Publishing Corporation
    Date: c1974
    Physical Description: x, 413 p. : ill. ; 24 cm.
    Call Number: TH9145 .N70 1974
    FSI Number: B 002867
    Availability: Available on Interlibrary Loan
    Record Number: 1 of 5
    ..................

    Hi,
    Some where in java.sun.com had a good tutorial in using session objects under scope objects... but now I can't find it... any way... look at the following links..
    http://java.sun.com/j2ee/1.4/docs/tutorial/doc/Servlets11.html#wp64744
    http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/http/HttpSession.html
    You can use that documentation to create a session object and 'add' your vector to that session object which will stay as long as you dont close the session (you can go back and forth within the website, and still get the variables added to the session object, until you remove it from the session or close the session)
    If you need some code samples... let me know and I will dig it up from my old projects and paste it here... but you should be able to do it without that, coz it is relatively easy to do...
    Good luck
    Rajesh

  • How to get DBconnection from a custom servlet

    Hi all:
    In my JHeadstart Struts application, if we will using javascript to call a custom servlet program when some html event occur,
    than how can we get db connection in our Servlet because we need get some database data through this Servlet,
    we hope this Servlet can share dbconnection pool with JHeadstart that is consider for performance issue.
    thanks a lot !

    Ting Rung,
    JHeadstart is based on the Model-View-Controller (MVC) principle. This means that the Model layer is responsible for communication with the database (and thus database connection pooling). Accessing the database directly from a JSP or Servlet is against the principles of MVC. JHeadstart uses BC4J as the technology to implement the model layer. By going through an BC4J Application Module to do some database action (for example calling a stored procedure as you mentioned in another thread) you automatically get the database connection pooling.
    So, in the JHeadstart philosophy, we do not access the database from a servlet, instead we would do the following:
    - write a method on the BC4J app module that performs the database action
    - add a method to the apporpriate handler that calls this AM method
    - write a custom Struts action that calls the handler method
    Having said this, nobody will stop you from doing database access in a servlet. But JHeadstart might not be the right choice for you if you do not want to stick with the principles of MVC.
    Here is a link that provides you with some more background information about MVC, may be it can help you deciding what the best approach for your application is:
    http://java.sun.com/blueprints/guidelines/designing_enterprise_applications_2e/web-tier/web-tier5.html
    You can also "google" on model-view-controller if you like.
    Steven Davelaar,
    JHeadstart Team.

  • Calling Oracle Reports from a servlet

    Hi
    I want use Oracle Reports to build reports
    and then call them from a servlet via a URL.
    How can i do this?
    Thanks
    Alexandre Baptista

    You can write a Java Stored Procedure that executes a Java
    Runtime object. This allows you to call an OS command. It's
    quite straightforward to do and you can find examples on this
    forum and on the AskTom site (among other places).
    With this Java built you ought (I haven't tried it myself) to be
    able to call run_product (or whatever the Reports runtime is
    these days) - providing it's on the same server as the
    database. I'm not sure whether you can use this java workaround
    to call OS commans on remote servers, although in principle I
    don't see why not.
    Try it and let the forum know how it works.
    HTH, APC

  • Get all values from multi select in a servlet

    Hello,
    I have a multi <select> element in a HTML form and I need to retrieve the values of ALL selected options of this <select> element in a servlet.
    HTML code snippet
    <select name="elName" id="elName" multiple="multiple">
    Servlet code snippet
    response.setContentType("text/html");
    PrintWriter out = null;
    out = response.getWriter();
    String output = "";
    String[] str = request.getParameterValues("elName");
    for(String s : str) {
    output += s + ":";
    output = output.substring(0, output.length()-1); // cut off last deliminator
    out.println(output);But even when selecting multiple options, the returned text only ever contains the value of the first selected option in the <select>
    What am I doing wrong? I'm fairly new to servlets
    Edited by: Irish_Fred on Feb 4, 2010 12:43 PM
    Edited by: Irish_Fred on Feb 4, 2010 12:44 PM
    Edited by: Irish_Fred on Feb 4, 2010 2:14 PM
    Edited by: Irish_Fred on Feb 4, 2010 2:26 PM
    Edited by: Irish_Fred on Feb 4, 2010 2:26 PM
    Edited by: Irish_Fred on Feb 4, 2010 2:32 PM

    I am using AJAX.
    I will show you how I'm submitting the <select> values by showing you the flow of code:
    This is the HTML code for the <select> tag and the button that sends the form data:
    <form name="formMain" id="formMain" method="POST">
         <input type="button" id="addOpts" name="addOpts" value="Add Options" style="width:auto; visibility:hidden" onClick="jsObj.addOptions('servletName', document.getElementById('elName'))">
         <br>
         <select name="elName" id="elName" multiple="multiple" size="1" onChange="jsObj.checkSelected()">
              <option value="0"> - - - - - - - - - - - - - - - - </option>
         </select>
    </form>Note that the "visibility:hidden" part of the button style is set to "visible" when at least one option is selected
    Note that "jsObj" relates to a java script object that has been created when the web app starts ( The .js file is included in the .jsp <head> tag )
    The following code is taken from the file: "jsObj.js"
    jsObj = new jsObj();
    function jsObj() {
    //=================================================
         this.addOptions = function(url, elName) {
              var theForm = document.getElementById('formMain');          
              if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
                   xmlhttp=new XMLHttpRequest();
              } else { // code for IE6, IE5
                   xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
              url += this.buildQueryString(theForm.name);
              xmlhttp.open("POST",url,true);
              xmlhttp.send(null);
              xmlhttp.onreadystatechange=function() {
                   if(xmlhttp.readyState==4) { // 4 = The request is complete
                        alert(xmlhttp.responseText);
    //=================================================
    this.buildQueryString = function(formName) {
              var theForm = document.forms[formName];
              var qs = '';
              for (var i=0; i<theForm.elements.length; i++) {
                   if (theForm.elements.name!='') {
                        qs+=(qs=='')? '?' : '&';
                        qs+=theForm.elements[i].name+'='+escape(theForm.elements[i].value);
              return qs;
         //=================================================
    }And this is a code snippet from the "servletName" servlet:public synchronized void doGet(HttpServletRequest request,
              HttpServletResponse response) throws ServletException,IOException {
              PrintWriter out = null;
              try {
                   response.setContentType("text/html");
                   out = response.getWriter();
                   String output = "";
                   String[] values = request.getParameterValues("elName");
                   for(String s : values) {
                        output += s + ":";
                   output = output.substring(0, output.length()-1); // cut off last delimitor
                   out.println(output);
                   } catch (Exception e) {
         }So anyway, everthing compiles / works, except for the fact that I'm only getting back the first selected <option> in the 'elName' <select> tag whenever I select multiple options
    Edited by: Irish_Fred on Feb 7, 2010 10:53 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Open Jasper Report in new page using servlet

    Guys,
    Looks very simple but i am having problem making this process work. I am using 11.1.1.4
    This is my use case:
    - From a employee page, user clicks on a menu item to open report for current employee. I need to pass appropriate report parameters to servlet and open report into new page.
    I can successfully call servlet using commandmenuitem and set request parameters and call servlet from backing bean.... but that doesn't open report in a new page.... any way i can do this?
    Another option i tried was that using gomenuitem and setting target=blank but in that case i need to pass the parameter using servlet url which i like to avoid.(in case i need to pass many parameters in future) (also values will be set on page so i need to generate url when then click the menuitem...... so there are some hoops and loops i need to go through) I don't know a way to pass the request parameter using backing bean to servlet... i don't think it is possible.
    Those are the two approaches i tried.
    If you have any better approach...I would appreciate if you can let me know. (i have searched on internet for two days now.... for the solution)
    -R
    Edited by: polo on Dec 13, 2011 7:22 AM

    Hi,
    Hope following will useful
    http://sameh-nassar.blogspot.com/2009/10/using-jasper-reports-with-jdeveloper.html
    http://www.gebs.ro/blog/oracle/jasper-reports-in-adf/

  • How can i execute ejb method in a servlet?

    hi
    I am using a IBM HTTP Server and Weblogic Server.
    I could execute below source in a main method of application but i could not that in a init method of servlet because of ClassCastException.
    (a classpath of weblogic contains client's classpath)
    // source code
    Hashtable props = new Hashtable();
    props.pu(Context.INITIAL_CONTEXT_FACTORY,
    "weblogic.jndi.WLInitialContextFactory");
    props.put(Context.PROVIDER_URL,
    "t3://192.168.1.5:7001");
    Context ctx = new InitialContext(props);
    Object obj = ctx.lookup("session.LigerSessionHome");
    LigerSessionHome home = (LigerSessionHome) PortableRemoteObject.narrow (obj, LigerSessionHome.class);
    // error code
    Exception : session.LigerSessionBeanHomeImpl_ServiceStub
    java.lang.ClassCastException: session.LigerSessionBeanHomeImpl_ServiceStub
    at com.ibm.rmi.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:253)
    at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:136)
    at credit.getCreditResearch(credit.java:41)
    at creditResearchClient.doGet(creditResearchClient.java:122)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
    thanks

    Have your stubs somehow got out of sync? So that your Servlet engine is pointing to a different jar than that of your jvm on which you were running your client application
    hi
    I am using a IBM HTTP Server and Weblogic Server.
    I could execute below source in a main method of
    application but i could not that in a init method of
    servlet because of ClassCastException.
    (a classpath of weblogic contains client's classpath)
    // source code
    Hashtable props = new Hashtable();
    props.pu(Context.INITIAL_CONTEXT_FACTORY,
    "weblogic.jndi.WLInitialContextFactory");
    props.put(Context.PROVIDER_URL,
    "t3://192.168.1.5:7001");
    Context ctx = new InitialContext(props);
    Object obj = ctx.lookup("session.LigerSessionHome");
    LigerSessionHome home = (LigerSessionHome)
    PortableRemoteObject.narrow (obj,
    LigerSessionHome.class);
    // error code
    Exception :
    session.LigerSessionBeanHomeImpl_ServiceStub
    java.lang.ClassCastException:
    session.LigerSessionBeanHomeImpl_ServiceStub
    at
    com.ibm.rmi.javax.rmi.PortableRemoteObject.narrow(Porta
    leRemoteObject.java:253)
    at
    javax.rmi.PortableRemoteObject.narrow(PortableRemoteObj
    ct.java:136)
    at credit.getCreditResearch(credit.java:41)
    at
    creditResearchClient.doGet(creditResearchClient.java:12
    at
    javax.servlet.http.HttpServlet.service(HttpServlet.java
    740)
    at
    javax.servlet.http.HttpServlet.service(HttpServlet.java
    865)
    thanks

  • How to call a specific method in a servlet from another servlet

    Hi peeps, this post is kinda linked to my other thread but more direct !!
    I need to call a method from another servlet and retrieve info/objects from that method and manipulate them in the originating servlet .... how can I do it ?
    Assume the originating servlet is called Control and the servlet/method I want to access is DAO/login.
    I can create an object of the DAO class, say newDAO, and access the login method by newDAO.login(username, password). Then how do I get the returned info from the DAO ??
    Can I use the RequestDispatcher to INCLUDE the call to the DAO class method "login" ???
    Cheers
    Kevin

    Thanks for the reply.
    So if I have a method in my DAO class called login() and I want to call it from my control servlet, what would the syntax be ?
    getrequestdispatcher.include(newDAO.login())
    where newDAO is an instance of the class DAO, would that be correct ?? I'd simply pass the request object as a parameter in the login method and to retrieve the results of login() the requestdispatcher.include method will return whatever I set as an attribute to the request object, do I have that right ?!!!!
    Kevin

Maybe you are looking for