Calling servlet from a backing bean

hi guys i need to call a servlet from a backing bean in JSF. how do i do that ?
The scenario is i have to call servlet on a different machine from my backing bean . I also need to pass an object to the servlet .
This object contains data which must be manipulated and inserted in the database by the calling servlet.
I also want that after insertion in the db the control must be passed to the backing bean .
Is this all possible???
Please help

You may want to investigate the built in java.net.URL class. For advanced needs, Apache has a Java HTTP client library.

Similar Messages

  • Is it possible to call a custom method in App Module from a backing bean?

    I would like to know if a custom method in App Module can be called from inside a backing bean.
    I am not sure if it is logically right to call, from a backing bean, a custom method in App Module. But would like to know if that makes sense or if it is possible.

    Hi..
    Yes it is possible.You have to add that method for client interface of AppModule.Now you can see that method in Data Controls(Refresh the data control). To call this method using bean it should add as method action to bindings(Click Bindings>+>methodAction>and Create action binding).
    Now you can call this method in bean class.
    Check following example use this concept to execute view criteria
    http://adf-lk.blogspot.com/2011/05/oracle-adf-create-view-criteria-and_4727.html

  • Error when I call a method of AppModule from a backing bean.

    I use Jdeveloper 10.1.3.0.3 EA.
    In my application I have created ApplModule and UsrView(for my table USR).
    I have a login page (login.jsp and the backing login.java) with 2 fields userName and password and an ADF Faces Core command button (cmdCheckPass) and the method cmdCheckPass _action() for the click event .
    The problem is that I can’t call method testPassword(userName, password) which is written in AppModule. (I get error:
    javax.faces.FacesException: #{backing_login.cmdCheckPass_action}: javax.faces.el.EvaluationException: java.lang.NullPointerException) from line:
    answer = app.testPass(st1,st2);
    The code is as follows:
    public String cmdCheckPass_action() {
    String answer="";
    String mes = "";
    String st1=this.getInputText1().getValue().toString();
    String st2=this.getInputText2().getValue().toString();
    AppModuleImpl app = new AppModuleImpl();
    answer = app.testPass(st1,st2);
    if (answer == "OK") {
    return "toMain";
    } else {
    answer = "";
    mes="Invalid username, password !!!";
    FacesContext.getCurrentInstance().addMessage(null,new FacesMessage(mes));
    return answer;}
    I don’t know if theoretically is right to call, from a backing bean, a custom method of AppModule.
    Can I have any help on this?
    Thanks in advance,
    Panos

    Some quick ideas:
    Is the clip the same NTSC/PAL standard as the project you are importing it to?
    Have you tried to rename the offending clip (do NOT rename any clips inside the iMovie /Media folder!!).
    How much free space do you have on the iMovie project volume -- what is the size of the imported clip?

  • The difference in calling an application module from a backing bean

    Hello everybody!
    I don't understand exactly, where is the difference in calling an application module from a backing bean in the following ways.
    Example 1
    FacesContext context = FacesContext.getCurrentInstance();
    ValueBinding vb = context.getApplication().createValueBinding("#{data}");
    BindingContext bc = (BindingContext)vb.getValue(context);
    DCDataControl dc = bc.findDataControl("AppModuleDataControl");
    AppModuleImpl appModule = (AppModuleImpl)dc.getDataProvider();Example 2
    String amDef = "model.services.AppModule";
    String config = "AppModuleLocal";
    AppModuleImpl appModule = (AppModuleImpl)Configuration.createRootApplicationModule(amDef, config);Example 3 (the same like Example 1???)
    String EL = "#{data.AppModuleDataControl.dataProvider}";
    FacesContext fc = FacesContext.getCurrentInstance();
    ValueBinding vb = fc.getApplication().createValueBinding(EL);
    AppModuleImpl appModule = (AppModuleImpl)vb.getValue(fc);Please can anybody explain, what the three examples do? Which example is preferred to call an application-module-method from a backing bean?
    Thanks and regards
    Majo
    Edit: I am using ADF BC 10g in JDev10 :)

    Hi :)
    >
    This could work, but can you describe the use case for which you need to get the ApplicationModule?
    Maybe we can find a better way to implement your functionality.
    >
    Sure, i know a lot of better ways to implement the same functionality too but its a huge project, its not my code and we have no time to reimplement this functions ;)
    Frank, i don't understand the first line of your code.
    DCBindingContainer bindings = ... resolve #{bindings}Where do i get the bindingContainer, if I don't have the "JSFUtils"- or "ADFUtils"-classes?
    Regards
    Majo
    Edit:
    Sorry, i have answer, before i think about it ;)
    FacesContext context = FacesContext.getCurrentInstance();
    Application app = context.getApplication();
    DCBindingContainer bindings = (DCBindingContainer)app.getVariableResolver().resolveVariable(context, "bindings");
    BindingContext bctx = bindings.getBindingContext();
    DCDataControl dc = bctx.findDataControl("AppModuleDataControl");
    AppModuleImpl am = (AppModuleImpl)dc.getDataProvider();or in my backing bean, when i add the property to the faces-config.xml
    DCBindingContainer bindings = this.getBindings();
    BindingContext bctx = bindings.getBindingContext();
    DCDataControl dc = bctx.findDataControl("AppModuleDataControl");
    AppModuleImpl am = (AppModuleImpl)dc.getDataProvider();Is this right?

  • Call a Function From a Backing Bean

    Hello,
    I am trying to call a PL/SQL function from a Backing Bean but i am getting a getDBTransaction error. Here is the example i was trying to do in a backing bean.
    I Am getting the employee ID , sending it to a function that calculates the annual salary and then through a button whose code is in the backing bean, showing a message on the screen with the annual salary.
    I am getting the JBO-25301 error.
    Can't i use getDBTransaction in my backing bean.

    Please have a look at the following thread:
    Stored Procedure

  • How to call a method in backing bean on hitting 'Enter' key on a page.

    Hi all,
    I would be obliged if any one can provide me solution for the below given problem.
    My requirement is to call a method in backing bean when i hit 'Enter' key on a JSP page.
    I am trying this by using a script given below.
    *function fnChangeFocus(){*
    *if(window.event.keyCode==13){*
    * document.getElementById("mainform:submitForm:commandbutton").focus();*
    The JSP has the textbox as given below.
    *<h:inputText id="inputtxtboxid" disabled="false" value="#{Bean.inputvalue}"*
    onkeypress="fnChangeFocus()" size="24" />
    Using this I could not acheive the required functionality. Please suggest some alternative.
    Thanks,
    Jagadeesh Pala

    Only a form element supports the submit() function. Make sure that the getElementById returns the appropriate form. Or rather pass the element as the 'this' reference to the function and get the parent form from it.
    After all this is just basic DHTML / Javascript+DOM knowledge and in fact this has nothing to do with JSF. For future basic DHTML / JS+DOM questions you may take a look at the appropriate forums, e.g. dhtmlcentral.com, dynamicdrive.com, etcetera.

  • Calling Servlet from a java prog?

    Hi all,
    I am calling servlet from a java prog (Java Agent in Lotus Notes) by using URL and URLConnection object. how can i trigger the Servlet By using doPost method .I have to send some parameter also.
    Thanx
    Muthu

    you need to open a connection to the servlet. Then you must call getInputStream() and getOutputStream() and use them in any way you see fit. I was trying this before and could not get POST to work unless I openned the input stream from the servlet. Strange... but doGet worked without openning the input stream???
    // open a connection....
    // write to the servlet
    servletConnection.getOutputStream().write("whatever");
    servletConnection.getOutputStream().flush();
    servletConnection.getOutputStream().close();
    // grab what the servlet sends back, required to do a post.
    byte [] in = new byte[100];
    servletConnection.getInputStream().read(in);
    servletConnection.getInputStream().close();

  • Accessing a JSF element from a back bean method

    Hi,
    short question, can I access the JSF element from a back bean method?
    So, for example, if I have the following JSF code:
    <h:panelGroup id="test1" rendered="#{bean.someMethod}">...</h:panelGroup>
    <h:panelGroup id="test2" rendered="#{bean.someMethod}">...</h:panelGroup>
    <h:panelGroup id="test3" rendered="#{bean.someMethod}">...</h:panelGroup>
    Can I found out in some way, which element (esp. which ID) calls the someMethod-method?
    Kind regards
    Matthias

    There are more possibilities as well. If you depend it on for example the User's rights/groups, then you can also do for example:
    rendered="#{user.admin}" // getter = public boolean isAdmin()
    rendered="#{user.groupName == 'admin'}" // getter = public String getGroupName()
    rendered="#{user.groupId > 1}" // getter = public int getGroupId()
    rendered="#{fn:contains(user.groups, 'admin')}" // getter = public String[] getGroups() or public List<String> getGroups()
    etc..I think it's after all just a matter of learning about the capabilities of EL a bit more.

  • Calling a method on backing bean in response to contextual event

    Hi
    I am using Jdeveloper 11.1.1.6.0 and using ADF contextual events..
    I have a drop down list and i am rasiing a contextual event on changing the current selection. In response to that event i want to call a backing bean method with parameters.. But when i click on the subscriber section for the contextual event, i can see only some bindings of the page.. How can i call a method on backing bean as a subscriber..
    Thanks
    Raghu

    Hi,
    this article has a use case for the POJO approach: http://www.oracle.com/technetwork/issue-archive/2011/11-may/o31adf-352561.html
    Another is to define a method binding in the receiving PageDef file and configure it as explained here
    http://java.net/projects/smuenchadf/pages/ADFSamplesBindings/revisions/3#SMU164
    Frank

  • Calling servlet from a java program

    Hi
    I need to call a servlet's doPost() method from a java program. I have a specific situation, where I need to call servlet from a java program. DUring this call I need to pass a file and two string to the servlet. Servelt after receiving the file and string uploads the file to the server at a specified location. I am stuck up as how to call servlet from a java program instead of a HTML or JSP.
    Can anyone help me to start with this.
    any suggestion is welcome.

    You have to establish a URLConnection with servlet from your java program.
    URL servletURL = new URL("http://localhost:8080/Myservlet?str1=abc&str2=def");
    URLConnection servletConnection = servletURL.openConnection();you can get the objectOutputStream
    ObjectOutputStream oos = new ObjectOutputStream (servletConnection.getOutputStream());
    oos.writeObject(your file object);-------------------------------------------------
    In the servlet u can get the strings using request.getParameter("str1");
    In the servlet u can get the strings using request.getParameter("str2");
    file = new ObjectInputStream (request.getInputStream()).readObject()a lot of resources are available on this ...
    hope this helps :)

  • How to set values in a CoreTable programmatically from a backing bean

    Hi,
    One of the columns in my CoreTable is "af:inputText" field, I need to set the value of inputText field in each row from a backing bean.
    I have bound this table to a component in the bakcing bean and in the setMyCoreTable method I'm also preselecting certain rows. For all the preselected rows I need to set a value in the inputText field.
    Can someone point me to some code samples or give me some ideas to solve this.
    Thanks

    Thanks dvohra,
    I looked at the post you suggested yesterday, but I wasnt sure how I can implement that in my case.
    Since Im programatically preselecting certain rows in the setMyCoreTable method(which is the accessor method), I was hoping I could prepopulate the input text field as well in the same method.
    For your reference below is the code from jspx and the backing bean.
    <af:table value="#{bindings.ProgramComponentList.collectionModel}"
    var="row"
    rows="#{bindings.ProgramComponentList.rangeSize}"
    first="#{bindings.ProgramComponentList.rangeStart}"
    emptyText="#{bindings.ProgramComponentList.viewable ? 'No rows yet.' : 'Access Denied.'}"
    selectionState="#{bindings.ProgramComponentList.collectionModel.selectedRow}"
    selectionListener="#{bindings.ProgramComponentList.collectionModel.makeCurrent}"
    binding="#{backing_EditProgramBean.compsTableComponent}">
    <af:column sortProperty="Name" sortable="true"
    headerText="#{bindings.ProgramComponentList.labels.Name}">
    <af:outputText value="#{row.Name}"/>
    </af:column>
    <af:column sortProperty="Description" sortable="true"
    headerText="#{bindings.ProgramComponentList.labels.Description}">
    <af:inputText value="#{row.Description}" simple="true"
    required="true"
    columns="30"/>
    </af:column>
    <f:facet name="selection">
    <af:tableSelectMany id="tableSelectMany1"/>
    </f:facet>
    </af:table>
    CODE FROM BACKING BEAN ---------
    public void setCompsTableComponent(CoreTable compsTableComp) {
    ManageProgramsServiceImpl serviceImpl =
    (ManageProgramsServiceImpl)JSFUtils.get("#{bindings.ProgramDetailIterator.dataControl.dataProvider}");
    ViewObject searchProgramView = serviceImpl.findViewObject("SearchProgramView");
    Row currProgram = searchProgramView.getCurrentRow();
    ViewObject view = serviceImpl.findViewObject("ProgramComponents");
    view.setWhereClause("ProgramsComponents.PROGRAM_ID = " + currProgram.getAttribute("ProgramId"));
    view.executeQuery();
    view.setRangeSize(view.getRowCount());
    view.executeQuery();
    Row[] programComponents = view.getAllRowsInRange();
    RowKeySet rks = new RowKeySet();
    ViewObject compTypesView = serviceImpl.findViewObject("ProgramComponentList");
    compTypesView.setRangeSize(compTypesView.getRowCount());
    compTypesView.executeQuery();
    Row[] compTypes = compTypesView.getAllRowsInRange();
    for (int i = 0; i < compTypes.length; i++) {
    String code = compTypes.getAttribute("Code").toString();
    for(int j=0; j<programComponents.length; j++){
    String programCode = programComponents[j].getAttribute("ComponentType").toString();
    if(programCode.equalsIgnoreCase(code)){
    rks.getKeySet().add(compTypes[i].getKey());
    compsTableComp.setSelectionState(rks);
    List li = compsTableComp.getChildren();
    System.out.println("****** li : " + li.size());
    //System.out.println("****** row count : " + compsTableComp.getRowCount());
    //System.out.println("****** count : " + compsTableComp.getRows());
    this.compsTableComponent = compsTableComp;
    The table children size(li.size()) comes up as zero and [compsTableComp.getRowCount()] gives an exception. Can you please provide any help. Seems like Im off track with this whole thing.
    Thanks

  • Wot all ways are there to call servlet from jsp

    hi all
    i want to know wot all methods are available
    so that i can call servlet from jsp
    the one which i know is using RequestDispatcher
    wot are others ?
    thanx

    hi all
    i want to know wot all methods are available
    so that i can call servlet from jsp
    the one which i know is using RequestDispatcher
    wot are others ?
    thanxhi here are few ways... to call servlet from jsp...
    these are just generic syntax.
    Form:     
    <form action="ServletPath">
    Link:     
    Directives & Action tags :
    <%@ page import="ServletPath" %>
         <%@ taglib uri="ServletPth" %>
         <jsp:include page="ServletPath">
         <jsp:forward page="ServletPath">
         <jsp:useBean class="ServletPath"> (Not sure about this useBean)
    hope you got your answer.
    regards,
    immu

  • How to call Servlet from jsp page and how to run this app using tomcat..?

    Hi ,
    I wanted to call servlet from jsp action i.e. on submit button of JSP call LoginServlet.Java file.
    Please tell me how to do this into jsp page..?
    Also i wanted to execute this application using tomcat.
    Please tell me how to do this...? what setting are required for this...? what will be url ..??
    Thanks.

    well....my problem is as follows:
    whenever i type...... http://localhost:8080/appName/
    i am getting 404 error.....it is not calling to login.jsp (default jsp)
    but when i type......http://localhost:8080/appName/login.do........it executes servlet properly.
    Basically this 'login.do' is form action (form action='/login.do').....and i wanted to execute this from login jsp only.(from submit button)
    In short can anyone please tell me how to diaplay jsp page using tomcat 5.5
    plz help me.

  • Calling servlets from main()?

    Hi
    I would like to know that while calling servlets from another class having main(), how can we set the type of request i.e. put, post or get?
    Thanks

    use the method - setRequestMethod( "POST") of HttpURLConnection for setting the method to POST.Similarly for other methods..
    You could find [url http://java.sun.com/developer/JDCTechTips/2004/tt0210.html#2]this useful

  • Redirect from JSF backing bean to another application

    Hi,
    I need to open another (non-JSF) application in a new window from the backing bean of my JSF application.
    My JSF application is in frames. - heading, menu, content.
    I've a commandlink in the menu frame.
    I tried with
    FacesContext.getCurrentInstance().getExternalContext().redirect(loginUrl);
    This is opening in the menu frame itself.
    I tried using target="new" , but no result.
    I also need to pass the userId to the external application.
    Any ideas?
    ~Thanks.

    Thanks.
    Yes, GET works. I used a <h:outputLink and used target="new" and
    window.open("url?userId=someId")
    But i donot want to pass userid in GET in the url, since that is a sensitive information.
    Please let me know if there's any other way.
    Thanks,

Maybe you are looking for

  • Automatic Rule Determination Based on Service Order Type

    Hi Experts, I have a requirement to determine the rule based on the custom service order type. I have created 2 custom rules which are then assigned to 2 different org units as needed. Now the thing is i want to avoid putting condition step if else b

  • Can I retrieve photos burned onto DVD (I used iDVD)?

    I lost my hard drive last week and am in the process of rebuilding my photo gallery. In Decemeber, I burned a DVD with all of my desired photos from 2012 using iDVD. In addition to the videos and slideshows that I included in the main menu, I made su

  • I cannot get back into my eprint account.

    I cannot get back into my eprint account. It will not recognize my password and when I click on "Can't Remember Password" and go to the page where I need to enter my account email address it will not recognize it. It's the same email address that app

  • Itunes - disable, would you like to download this now

    Each time I download from itunes the dialog box keeps asking me the same question ."would you like to download this now" How do I disable this permanently?

  • Sync not syncing

    Installed newest version of Firefox on my laptop and created a sync account. Laptop showed that it synced. Installed newest version of Firefox for Android on my Samsung Galaxy Note 3. Signed in to sync using my new account name. It said it would star