How to invoke a Servlet method from application

please help me.the scenario is as follows
1)a servlet is placed on the server and application has invoked servlet with URL and URL Connection class
but how do i call a certain method of servlet on the server from the application.Let suppose the servlet's method to be invoked is print(String s).How it can be done from application.

As GrayMan suggested, Servlets are intended to be used for HTTP communication.
If you want to open common logic to multiple clients, use EJBs, CORBA or some type of Web Service (SOAP, XML-RPC).
When you send a request to a servlet, the doPost or doGet method will be invoked. Products such as STRUTS allow you do 'map' to other classes. I suggest avoiding this.
Personally, I avoid STRUTS like a bad disease. Using STRUTS instead of just learning Servlets/JSP adds a lot of overhead. I prefer performance over development time. A good example of this is that ANY request that comes in over the WEB has ALL variables from the calling page (text boxes, radio buttons and such) made avaialable through the HttpServletRequest.getParameter(String parameterName) method. STRUTS requires you to build a subclass of it's ActionForm classes that is nothing more than a JavaBean with fields that match that of the web page. STRUTS will look at all the parameters in the request and all the fields in the Bean and assign any matches from the request to the Bean. The Bean is instanciated and the matching logic performed just to give you access to objects you already have access to.
Just my 2 cents, avoid STRUTS like an STD.

Similar Messages

  • How to invoke a servlet from MDB

    Hi,
    Can someone please tell me how to invoke a servlet from MDB. Actually I want to have a MDB that will invoke a servlet that takes arround ~3 minutes to process and send the response back to MDB. Any small code snippet on invoking a servlet.
    Thanks

    nope. this is probably a bad design.
    but here's a hint: whenever you have a question like this, start browsing the javadocs. chances are there's a class that might help you.
    i'd recommend that you look at this:
    http://java.sun.com/javase/6/docs/api/java/net/HttpURLConnection.html
    %

  • How can I call a servlet method from a javascript function

    I want to call l a servlet method from a javascript function.
    Does any one have an example of code.
    Thinks in advance

    Actually, as long as the servlet returns valid javascript, you can indeed "call it" from the client. It will initiate a request and return the result to the browser.
    This example uses Perl, but it could be easily modified to go to a servlet instead.
    Note that it is only supported in DOM browsers (IE6+/NN6+/etc)
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
    <html>
    <head>
    <title> Test server-side JS </title>
    </head>
    <body>
    <script type="text/javascript">
    function checkIt(variable, value)
    var newScript = "cgi-bin/validateJS.cgi?"+variable+"="+value;
    var body = document.getElementsByTagName('body').item(0)
    var scriptTag = document.getElementById('loadScript');
    if(scriptTag) body.removeChild(scriptTag);
    script = document.createElement('script');
    script.src = newScript;
         script.type = 'text/javascript';
         script.id = 'loadScript';
         body.appendChild(script)
    </script>
    <p>Test.</p>
    <form id="f1" action="">
    <input type="text" name="t1" id="t1" onChange="checkIt(this.name, this.value)">
    </body>
    </html>
    validateJS.cgi
    #!/opt/x11r6/bin/perl
    use CGI qw(:all);
    my @valArray = split(/=/,$ENV{QUERY_STRING});
    print "Content-type: text/javascript\n\n";
    # myPass is the password
    $myPass = "foobar";
    if ("$valArray[1]" eq "$myPass")
    print "alert(\"Success!!\")";
    else
    print "alert(\"Failure!!\")";

  • How to call a bean method from javascript event

    Hi,
    I could not find material on how to call a bean method from javascript, any help would be appreciated.
    Ralph

    Hi,
    Basically, I would like to call a method that I have written in the page java bean, or in the session bean, or application bean, or an external bean, from the javascript events (mouseover, on click, etc...) of a ui jsf component. I.e., I would like to take an action when a user clicks in a column in a datatable.
    Cheers,
    Ralph

  • How to invoke a Servlet on onClick event of CheckBox ?

    Hi,
    Can anybody provide me with the code - how to invoke a Servlet & then pass all form variables to the Servlet on onClick Event of CheckBox in a JSP Page.
    I guess it is possible with Javascript but i need the code...
    Pls Help !
    Thanx.

    <html>
    <head>
    <script language="JavaScript">
    <!--
    function submitMyForm(){      
    document.myform.submit();
    //-->
    </script>
    </head>
    <body>
    <form name="myform" method="POST" action="http://mywebserver/servlet/myServlet" target=_top>
    <input type="checkbox" name="mycheckbox" OnClick = "javascript:submitMyForm()">
    </form>
    </body>
    </html>
    Hope this helps...

  • How to call jpf controller method from javascript

    Can any one help me how to call pageflow controller method from JavaScript.\
    Thanks.

    Accessing a particular pageflow method from Javascript is directly not possible unless we do some real funky coding in specifying document.myForm.action = xyz...Heres what I tried and it did not work as expected: I found another workaround that I will share with you.
    1. In my jsp file when I click a button a call a JavaScript that calls the method that I want in pageflow like this: My method got invoked BUT when that method forwards the jsp, it lost the portal context. I saw my returned jsp only on the browser instead of seeing it inside the portlet on the page of a portal. I just see contents of jsp on full browser screen. I checked the url. This does make the sense. I do not see the url where I will have like test1.portal?_pageLabe=xxx&portlet details etc etc. So this bottom approach will notwork.
    document.getElementById("batchForm").action = "/portlets/com/hid/iod/Batches/holdBatch"; // here if you give like test1.portal/pagelable value like complete url...it may work...but not suggested/recommended....
    document.getElementById("batchForm").submit;
    2. I achieved my requirement using a hidden variable inside my netui:form tag in the jsp. Say for example, I have 3 buttons and all of them should call their own action methods like create, update, delete on pageflow side. But I want these to be called through javascript say for example to do some validation. (I have diff usecase though). So I created a hidden field like ACTION_NAME. I have 3 javascript functions create(), update() etc. These javascripts are called onclick() for these buttons. In thse functions first I set unique value to this hiddent field appropriately. Then submit the form. Note that all 3 buttons now go to same common action in the JPF. The code is like this.
    document.getElementById("ACTION_NAME").value = "UPDATE";
    document.getElementById("batchForm").submit.
    Inside the pageflow common method, I retriev this hidden field value and based on its value, I call one of the above 3 methods in pageflow. This works for me. There may be better solution.
    3. Another usecase that I want to share and may be help others also. Most of the time very common usecase is, when we select a item in a drop bos or netui:select, we want to invoke the pageflow action. Say we have 2 dropdown boxes with States and Cities. Anytime States select box is changed, it should go back to server and get new list of Cities for that state. (We can get both states and cities and do all string tokenizer on jsp itself. But inreality as per business needs, we do have to go to server to get dynamic values. Here is the code snippet that I use and it works for all my select boxes onChange event.
    This entire lines of code should do what we want.
    <netui:anchor action="selectArticleChanged" formSubmit="true" tagId="selectPropertyAction"/>                    
    <netui:select onChange="document.getElementById(lookupIdByTagId('selectPropertyAction',this )).onclick();" dataSource="pageFlow.selectedArticleId" >
    <c:forEach items="${requestScope.ALL_ARTICLE}" var="eachArticle">
    <%-- workshop:varType="com.hid.iod.forms.IoDProfileArticleRelForm" --%>
    <netui:selectOption value="${eachArticle.articleIdAsString}">${eachArticle.articleItemName}</netui:selectOption>
    </c:forEach>               
    </netui:select>
    See if you can build along those above lines of code. Any other simpler approches are highly welcome.
    Thanks
    Ravi Jegga

  • Call VO method from application module

    Hi Experts.
    In my case I have created VO and inside implementation class custom method: filterResultsByGroup()
    code:
    public class VO_Business_AreaImpl extends ViewObjectImpl implements VO_Business_Area {
    public VO_Business_AreaImpl() {
    public void filterResultsByGroup() {
    System.out.println("hello");
    now... I would like to call filterResultsByGroup() method from Application Module Imp class:
    code:
    public class AppModuleImpl extends ApplicationModuleImpl implements AppModule {
    public AppModuleImpl() {
    public VO_Business_AreaImpl getVO_Business_Area1() {
    return (VO_Business_AreaImpl)findViewObject("VO_Business_Area1");
    public void RunGroupFilter(){
    ViewObjectImpl bussinesArea;
    bussinesArea = this.getVO_Business_Area1();
    ViewCriteria vc = bussinesArea.getViewCriteria("filterResultsByGroup();");
    bussinesArea.applyViewCriteria(vc);
    bussinesArea.executeQuery();
    but it doesn't work. Anyone knows how to call this method?
    Best Regards.

    you code should be like
    VO_Business_AreaImpl bussinesArea;
    bussinesArea = this.getVO_Business_Area1();
    bussinesArea.filterResultsByGroup();

  • How to have a live feed from application server log file (realtime viewr )

    how to have a live feed from application server log file (realtime viewr for apps log files)
    hi , thank you for reading my post.
    is there any way to have a live feed of Application server log ?
    for example is there any application that can watch the log file and show the changes as new log items come in ?
    can some one with more experience help ?

    Your question would be more suited to the Developer Forums
    http://devforums.apple.com
    but anyway...
    My goal is to develop a web application that is able to run on iPhone too, to capture the audio and video content from its camera and mic.
    Web Apps running in Safari don't have access to the camera or mic hardware.
    Or I should built a native application distributed through Apple store?
    That is your only option, although such a system already exists:
    http://itunes.apple.com/us/app/ustream-live-broadcaster/id319362690?mt=8

  • How to call a JSP page from Applications menu?

    Hi partners,
    I am still looking for "how to call a JSP page from Applications menu?", I mean instead of calling a form, I want to call a JSP page which is staying in a OC4J repository which is located in another server.
    Any idea will be really appreciated.
    Thanks in advance.
    Frank Mtz.

    Hi Frank,
    if u know the solution please share it with me. i'm looking for the same scenario.
    thanks in advance,
    anish

  • Adobe Configurator - how to invoke action or script from html widget?

    How to invoke action or script from html wiget in Adobe Configurator?
    Please help! I tried to make it about 5 hours!
    I need something like that:
    I click link or image
    ...and it runs action.
    Thanks!

    If you click on the question mark ( as shown below) on the right of Configurator  2 window
    the user guide installed on your computer within Configurator 2  will open
    Anyway once you have your action or script button  in your panel you must select it and configure it in the  inspector palette

  • How to invoke the servlet

    how to invoke a servlet using jsp
    containing JSF components
    how can we do this using creator ?
    having sucessfully executed the examples
    still dont know how to do it
    and also jsp source is quite different than normal jsp
    it doesnt allow jsp tags such as
    <%= "asdf"%>any help is great to me
    thanks in advance !
    cheers,
    shekar

    and also jsp source is quite different than normal
    jsp
    it doesnt allow jsp tags such as
    <%= "asdf"%>
    This is jsp syntax -- JSC uses jsf...:-(
    Regards,
    - D.t.O

  • How to invoke a Java Program from Oracle 10g?(uRGENT)

    Hello.
    I've a query, that i have a program, that basically retreives the records from the
    oracle table and then parser this information and then insert the values in corresponding database base tables. I want that, whenever the new program is inserted, a Trigger should fire and pass the most recently entered record to the Parser Program, means
    1) Firing a Trigge
    2)Storing the most latest data and pass it to the Parser PROGRAM
    Can someone tell me how to do this? How to invoke a Java Program from within the database? Please if anyone has examples provide me. Its very urgent and tell me what is the basic mechanism.
    Thankyou.
    Ben

    With Java Stored Procedures Java may be caleed from a database.
    http://www.oracle.com/technology/tech/java/jsp/index.html

  • How I can change Valuation Method from Moving Average to Standar

    Hi Experts:
    How I can change Valuation Method from Moving Average to Standar for an item that has bookings. We running Sap Business One 2007 A, PL 45...
    Thanks very in advance.
    Claudia

    Hi
    You can change the valuation method, but for that you need to have zero physical stock for that item.
    Make a Goods issue entry for that Item for all the warehouses, change the method and make goods receipt entry for that item for all the warehouse.
    Regards
    Kamlesh

  • How do you call a method from  another class without extending as a parent?

    How do you call a method from another class without extending it as a parent? Is this possible?

    Why don't you just create an instance of the class?
    Car c = new Car();
    c.drive("fast");The drive method is in the car class, but as long as the method is public, you can use it anywhere.
    Is that what you were asking or am I totally misunderstanding your question?
    Jen

  • How to call backing bean method from java script

    Hi,
    I would like to know how to call backing bean method from java script.
    I am aware of serverListener and [AjaxAutoSuggest article|http://www.oracle.com/technology/products/jdev/tips/mills/AjaxAutoSuggest/AjaxAutoSuggest.html]
    but i am running in to some issues with [AjaxAutoSuggest article|http://www.oracle.com/technology/products/jdev/tips/mills/AjaxAutoSuggest/AjaxAutoSuggest.html]
    regarding which i asked for help in other thread with subject ....Question on AjaxAutoSuggest article (Ajax Transactions Using ADF and J...)
    The reason why i posted is ( though i realise both are duplicates) .. that threads looks as a specific question to that article hence i would like to ask the quantified problem is asked in this thread.
    So could any please letme know how to call backing bean method from java script
    Thanks
    Murali
    Edited by: mchepuri on Oct 24, 2009 6:17 PM
    Edited by: mchepuri on Oct 24, 2009 6:20 PM

    Hello,
    May know how to submit a button autoamtically on onload of page with clicking a welcome alert box. the submit button has managed button too to show a message on console using SOP.
    the problem is.
    1. before loading the page a javascript comes on which i clicked ok
    2. the page gets loaded and the button is there which gets automatically clicked and the managed bean associated with prints a message on console using SOP.
    I m trying to do this through server listener and click listener. the code is(adf jspx page)
    <?xml version='1.0' encoding='UTF-8'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
    <jsp:directive.page contentType="text/html;charset=UTF-8"/>
    <f:view>
    <af:document id="d1" binding="#{backingBeanScope.backing_check4.d1}">
    <af:form id="f1" binding="#{backingBeanScope.backing_check4.f1}">
    <af:commandButton text="commandButton 1"
    binding="#{backingBeanScope.backing_check4.cb1}"
    id="cb1" action="#{beanCheck4.submit1}"/>
    <af:clientListener type="click" method="delRow"/>
    <af:serverListener type= "jsServerListener"
    method="#{backingBeanScope.backing_check4.submit1}"/>
    <f:facet name="metaContainer">
    <af:resource type ="javascript">
    x=confirm("hi");
    // if(x){
    delRow = function(event){
    AdfCustomEvent.queue(event.getSource(), "jsServerListener", {}, false);
    return true;
    </af:resource>
    </f:facet>
    </af:form>
    </af:document>
    </f:view>
    <!--oracle-jdev-comment:auto-binding-backing-bean-name:backing_check4-->
    </jsp:root>
    the backing bean code is -----
    public class classCheck4 {
    public classCheck4() {
    public String submit1() {
    System.out.println("hello");
    return null;
    }

Maybe you are looking for

  • Need help with smooth scrolling of a sprite

    Hi All, Something that i have had many problems over the years with is creating the same nice smooth scrolling effect that i see on many sites (my scrolling always appears jerky in AS2 even when done on a movieClip with a high framerate - with onEnte

  • ABAP Runitme Errors (SAPBATCH - CALL_FUNCTION_CONFLICT_LENG,SAPBATCH - CALL

    Hi Friends, For the last few weeks  we have been receiving the same runtime errors when I perform the daily checks SAPBATCH - CALL_FUNCTION_CONFLICT_LENG SAPBATCH - CALL_FUNCTION_UC_STRUCT Please help me if any one have idea and is this something we

  • Encore CS5 loud transcoding

    Hi first time posting here. AMD Phenom II X4 965 3.4ghz 1.5TB HD ATI HD 5570 1024 12GB Corsair memory Win 7 64 Ultimate Encore CS5 It never use to happen when I burned dvds with Encore but now every DVD I build a project. During Transcoding the PC ge

  • Can I upgrade to Mountain Lion with Boot Camp windows 7?

    Can I upgrade my mac book pro to Mountain Lion when I have Boot Camp Windows 7?

  • Elements 11 backup

    I am using Elements 11. My photos are on an external drive, not the C drive where the program resides. Can I backup my catalog to a second external hard drive. I was told  by tech support while using Elements 10 that I would not be able to do a backu