Pass Parameter to Servlet

How can i pass parameter from a JSP form (depends on what user chooses from a select box to a Servlet.
I need to call multiple query based on what parameter choosen and display the result in table view.
Example :
1. User select choice1 from JSP form -> Servlet : call query Select * from Table1 where cond = choice1;
2. User select choice2 from JSP form -> Servlet : call query Select * from Table1 where cond = choice2;
Any sample code?
Thanks for any help.

Thanks melondck.
I have this Servlet which i want it to run queries and display results in table format. I know there's something wrong with the code. But i am new to Servlet/Java. Thanks for anyone who point me the mistakes. Thanks.
<code>
package mypackage;
import java.sql.*;
import javax.servlet.http.*;
import java.io.*;
import javax.servlet.*;
public class DisplayServlet extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse rsp)
throws ServletException, IOException {
rsp.setContentType("text/html");
String url="jdbc:mysql://localhost/smdb";
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
String query;
ServletOutputStream out = rsp.getOutputStream();
PrintWriter out1 = rsp.getWriter();
String answer = req.getParameter("answer");
out1.println("<html>");
out1.println("<head><title> Inventory: </title></head>");
out1.println("<body>");
if (answer == null) {
StringBuffer action = HttpUtils.getRequestURL(req);
out1.println("<form action=\"" + action + "\" method=\"POST\">\n");
out1.println("<p><b>Please select:</b></p>");
out1.println("<p><input type=\"radio\" name=\"answer\" " +
"value=\"A\" /> Display All <br />");
out1.println(" <input type=\"radio\" name=\"answer\" " +
"value=\"B\" /> Device <br />");
out1.println(" <input type=\"radio\" name=\"answer\" " +
"value=\"C\" /> Manufacturer <br />");
out1.println(" <input type=\"radio\" name=\"answer\" " +
"value=\"D\" /> Location <br />");
out1.println(" <input type=\"submit\" value=\"Submit\" /></p>");
out1.println("</form>");
} else {
try {
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection (url, "user", "mypass");
stmt = con.createStatement();
if (answer.equals("A")) {
query = "SELECT Device, LocFloor FROM Inventory";
esleif (answer.equals("B)) {
query = "SELECT Device, LocFloor FROM Inventory where ....";
ResultSet result = stmt.executeQuery(query);
//Display the result set in a HTML table
out.println("<HTML><HEAD><TITLE>List</TITLE></HEAD>");
out.println("<BODY>");
out.println("<FORM NAME='form' ");
out.println("METHOD='GET'><TABLE BORDER='1' CELLSPACING='2' CELLPADDING='2'>");
out.println("<TR><TH></TH><TH>Device Type</TH><TH>Floor</TH></TR>");
while(result.next()) {
String type = result.getString("Device");
String flr = result.getString("LocFloor");
out.println("<TD>" + type + "</TD>");
out.println("<TD>" + flr + "</TD>");
catch(ClassNotFoundException e) {
out.println("Could not load database driver: " + e.getMessage());
catch(SQLException e) {
out.println("SQLException caught: " + e.getMessage());
finally {
//close the database connection.
try {
if (con != null) con.close();
catch (SQLException e) {}
out.println("</body></html>");
</code>

Similar Messages

  • Cannot pass parameter to servlet

    dear all,
    I am writing a MIDlet to post some data to a servlet.At the MIDlet, i set as below:
    String url = getAppProperty("Login.URL");
    conn = (HttpConnection)Connector.open(url);
    conn.setRequestMethod(HttpConnection.POST);
    conn.setRequestProperty("User-Agent", "Profile/MIDP-1.0 Configuration/CLDC-1.0");
    conn.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
    conn.setRequestProperty("Accept", "application/octet-stream" );
    conn.setRequestProperty("Connection", "close" );
    os = conn.openOutputStream();
    byte data [] = ("userid="+userid.getString()).getBytes();
    os.write(data);
    data = ("&password="+password.getString()).getBytes();
    os.write(data);
    os.flush();
    At the servlet, I coded:
    String id = request.getParameter("userid"),
    pass = request.getParameter("password");
    When i posted "userid=123&password=123" to the servlet, the servlet directed me to 'LoginFail.jsp' with below output:
    Login fail!
    null //should be print out userid and password value
    can anyone please give me some suggestions, why the servlet cannot locate parameter and how to solve it?
    thanx a lot!

    <p>wongyuenmei</p>
    <p>I've done some similar program. I'm not sure why request.getParameter() won't return the value we past. However, I managed to resolve the problem with the following way:</p>
    <p>Remain your MIDlet code. But change your servlets to use the following rather request.getParameter()</p>
    <pre>
    ServletInputStream sis = request.getInputStream();
    DataInputStream din = new DataInputStream(sis);
    String id = din.getUTF();
    String pass = din.getUTF();
    </pre>
    <p>Good luck!</p>

  • Passing parameter from servlet to Javascript url

    Hi all,
    I want to pass the value of a selected option box in servlet as a parameter to a url in JavaScript.
    my java script code is :
    out.println("function reloadform() { ");
    out.println("alert('aacat');");
    out.println("location.href = 'http://localhost:8080/examples/servlet/frec1?aacatt=aacat';");
    out.println("}");
    and servlet code is :
    out.println("<td bgcolor=#F2F9FF> <select name=aacat size=1 style=font-size: 8pt; color: #666666; font-family: Verdana; border: 1 solid #666666 onChange= 'reloadform();'>");
    while (ra.next()==true) {
    String mycat=ra.getString("acat");
    String myasc=ra.getString("ascode");
    out.println(mycat+"<br>");
         out.println("<option value='"+mycat+"'><font face=verdana size=1>"+mycat+"</font></option>");
    Can anyone suggest me something on this ? Any Code reference will be highly appreciated.
    Thanks for any help in advance.
    savdeep.

    Please take care post the code in proper format...
    regarding the solution.. try something like..
    <select name=aacat size=1 style=font-size: 8pt; color: #666666; font-family: Verdana; border: 1 solid #666666 onChange= 'reloadform(this.options[this.selectedIndex].value);'>");also change the javascript code suitably

  • To pass Parameter to Servlet

    Hi,
    I have one servlet HTML page which gets the input from the user andon submittingthe form one mroe servlet is called which validates and dependig user value it will form the SQL select.
    Then I need to call Servlet which will generate an HTML page with the result set of the SQL.
    My problem is that from the processing form I need to send parameters and I am calling the final servlet usign forwardRequest. I formed the query string in teh form name=value and send the final string.
    I want to know whether they is any better way to achieve this.
    Please help me out!!!

    u can get parameters from the processing form using the HttpServletRequest.getParameter(String ..) method. once got into the first servlet on processing if u need to pass them onto the second servlet using the forward mechanism then u store these values into the HttpServletRequest.setAttribute(...) and using the getAttribute() methos can retrieve them in the other...

  • Passing parameter to servlet

    I can get a parameter with the ServletRequest.getAttribute(...) right?
    But how can I give the parameter to the servlet?
    Is it something like http://.../servlet/framePack.frameBase?table=env ?

    Yer confusing parameters with attributes.
    Parameters are something that are submitted by a html form.
    you should be using request.getParameter() to get those parameters.
    can get a parameter with the ServletRequest.getAttribute(...) right?refer to above.
    But how can I give the parameter to the servlet?There's nothing as setParameter(); It has to be given via form submission or by building an url of the form
    http://host:8080/yourapp/yourservlet?param1=val1&param2=val2.... and in the servlet you can get the values by doing a getParameter( on the request.
    Is it something like http://.../servlet/framePack.frameBase?table=env ?
    refer to above.

  • Passing parameter from Servlet to javascript in JSP. Very Urgent - 5 jukes!

    Well my servlet will retrieve questions from database.
    Then the player will answer the question in the JSP and submit the answer to the servlet to process.
    Each time an answer is submitted, or a "Next Question" button is clicked, the countdown time will restart.
    And will reload the page with a new question.
    So how can i do that?
    This is my servlet, JSP, javascript
    =====================================================================
    * Interacts with the player depending on his types of selection and output them
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.util.*;
    public class GameQuestionServlet extends HttpServlet
         String sSQL = null;
         String sCategory = null;
         String paramName = null;
         User userObject = null;
         Questions gameQsObj = new Questions();
         HttpSession session;
         int cnt = -1;
         int score = 0;
         boolean connected = false;
         public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
              session = request.getSession(false);
              //System.out.println("Testing Score:" + score);
              if(connected == true)
                   Questions object = (Questions)gameQsObj.getQsList().elementAt(cnt);
                   System.out.println("\n" + object.sAns1);
                   System.out.println(object.sAns2);
                   System.out.println(object.sAns3 + "\n");
                   Enumeration enum = request.getParameterNames();
                   while(enum.hasMoreElements())
                        paramName = (String)enum.nextElement();
                        if(paramName.equals("mcq"))
                             System.out.println(request.getParameter("mcq"));
                             score = Integer.parseInt(userObject.score.trim());
                             System.out.println("Player old score: " + score);
                             //Check to see if the selected answer matches the correct answer
                             if((object.sCorrect).equals(request.getParameter("mcq")))
                                  score = score + 10;
                             else
                                  if((object.sCorrect).equals(request.getParameter("mcq")))
                                       score = score + 10;     
                                  else
                                       if((object.sCorrect).equals(request.getParameter("mcq")))
                                            score = score + 10;     
                                       else
                                            score = score - 10;     
              System.out.println("Player current score: " + score);
              else     //will only go into this once
                   userObject = (User)session.getAttribute("user");
                   System.out.println("\n"+userObject.nric);
                   System.out.println(userObject.name);
                   System.out.println(userObject.password);
                   System.out.println(userObject.email);
                   System.out.println(userObject.score+"\n");
                   //depending on user selection
                   sCategory = request.getParameter("qsCategory");
                   sSQL = "SELECT * FROM " + sCategory;
                   gameQsObj.getQuestions(sSQL, sCategory);
                   score = Integer.parseInt(userObject.score);
                   connected = true;
              System.out.println("Connected:" + connected);
              System.out.println("Before:" + userObject.score);
              cnt = cnt + 1; //increment to retrieve next question
              userObject.score = Integer.toString(score);     
              System.out.println("After:" + userObject.score);
              if(cnt < 3) //setting for the number of questions per game.
                   //request.setAttribute("qsCnt", cnt); //count of the question number
                   request.setAttribute("aQs", gameQsObj.getQsList().elementAt(cnt));
                   System.out.println(request.getAttribute("aQs"));
                   System.out.println("This is question number: "+ cnt);
                   getServletConfig().getServletContext().getRequestDispatcher("/JSP/PlayGame.jsp").forward(request, response);
              else
                   //forward to the result page     
         public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
              doPost(request, response);
    <%@ page import="Questions" %>
    <HTML>
         <HEAD>
              <TITLE>Play Game</TITLE>
              <SCRIPT LANGUAGE="JavaScript">
                   var refreshinterval=10
                   var displaycountdown="yes"
                   var starttime
                   var nowtime
                   var reloadseconds=0
                   var secondssinceloaded=0
                   function starttime() {
                        starttime=new Date()
                        starttime=starttime.getTime()
                        countdown()
                   function countdown() {
                        nowtime= new Date()
                        nowtime=nowtime.getTime()
                        secondssinceloaded=(nowtime-starttime)/1000
                        reloadseconds=Math.round(refreshinterval-secondssinceloaded)
                        if (refreshinterval>=secondssinceloaded) {
                   var timer=setTimeout("countdown()",1000)
                             if (displaycountdown=="yes") {
                                  window.status="You have "+reloadseconds+ " second before timeout"
                   else {
                        hide();
                   clearTimeout(timer)
                             //window.location.reload(true)
                   function hide() {
                        //hidelayer
                        if(gameLayers.style.visibility == "visible"){
                             gameLayers.style.visibility = "hidden"
                             oops.style.visibility = "show"
                   window.onload=starttime
              </SCRIPT>
         </HEAD>
         <BODY>
              <FORM METHOD="post" ACTION="http://localhost:8080/Java_Assignment2/servlet/GameQuestionServlet">
                   <DIV ID="oops" STYLE="position:absolute; left:300px; top:30px; width:120px; height:150px; z-index:2; visibility:hidden">
                        Oops! 30 seconds time up!!! <BR><BR>
                        <INPUT TYPE="submit" VALUE="Next Question">
                        <INPUT TYPE="hidden" NAME="nextQs" VALUE="Next Question">
                   </DIV>
                   <DIV ID="gameLayers" STYLE="position:absolute; left:300px; top:30px; width:120px; height:150px; z-index:3; visibility:show">
                   <TABLE BORDER="0">
                        <TR>
                             <TH><BIG>Questions:</BIG></TH>
                        </TR>
    <%
                        Questions aQsObj = (Questions)request.getAttribute("aQs");
                        String aQsBody = aQsObj.sQs;
                        String aQsAns1 = aQsObj.sAns1;
                        String aQsAns2 = aQsObj.sAns2;
                        String aQsAns3 = aQsObj.sAns3;
    %>
                        <TR>
                             <TD><B><%= aQsBody%></B></TD>
                        </TR>
                        <TR>
                             <TD>
                                  <SELECT SIZE="3" NAME="mcq">
                                       <OPTION SELECTED><%= aQsAns1 %></OPTION>
                                       <OPTION><%= aQsAns2 %></OPTION>
                                       <OPTION><%= aQsAns3 %></OPTION>
                                  </SELECT><BR><BR>
                             </TD>
                        </TR>
                        <TR>
                             <TD>
                                  <INPUT TYPE="submit" VALUE="Submit Your Answer">
                                  <INPUT TYPE="hidden" NAME="submitAns" VALUE="Submit Your Answer">
                             </TD>
                        </TR>
                   </TABLE>
                   </DIV>
              </FORM>
         </BODY>
    </HTML>
    This must be answered before 28th of september.
    Please help. It is indeed very urgent.

    this is just a skeleton code.. alot of stuff is not here..
    <FORM name = "form1" action="../servlet/wateverSevlet>
    <input type="text" name="searchStr" size="40">
    <INPUT type="hidden" id=answer name=answer size=7>
    <input type="button" name="button" value="Submit Answer" onClick="javascript:submitCheck(document.form1.searchStr.value);">
    <input type="button" name="button" value="Skip Question" onClick="javascript:submitCheck('skip');">
    </form>
    <SCRIPT LANGUAGE="JavaScript">
    function submitCheck(str)
      form1.answer.value = str
      form1.submit()
    </script>i assuming you are submitting it to the same servlet regardless of whether the user clicks the skip question or the submit question button.

  • Servlet to pass parameter to another servlet

    Hi, I have a question. I have two servlets, servler A and servlet B. I wanna do this:
    1)servlet A to pass a parameter to servlet B. No redirect is required.
    2)servlet B to accept the parameter.
    How do I do that?
    Thanks

    1)servlet A to pass a parameter to servlet B. No redirect is required.
    2)servlet B to accept the parameter.I completely agree with what capitao suggested.
    As U said tht u need not require a redirect functionality
    U actually need to implement a proxy kind of mechanism in this case
    You may also go by using HttpURLConnection Object to retrive the info by passing few parameters.
    checkout an eq code down below
    HttpURLConnection server = (HttpURLConnection)(new URL("http://<hostname>:<port>/servletC")).openConnection();
    server.setRequestProperty("testParam","testParam");
    InputStreamReader isr = new InputStreamReader( server.getInputStream() );
    BufferedReader in = new BufferedReader( isr );
    response.setContentType( "text/html" );
    PrintWriter outStr = response.getWriter();
    String line = "";
    while((line = in.readLine()) != null) {
    outStr.println( line );
    }

  • Passing parameter value via href in a servlet to another servlet

    Hi
    I have this issue with passing a value from one servlet to another servlet. the situation is is this.
    i have a servlet tstret.java which say..pulls out all the employee_id(s) from a table and displays it as hyperlinks( using the anchor tag.).
    now when i click on the hyperlink say T001 , The control is passed to another servlet which pulls out all the info about employee id T001.
    the problem i have is in the tstret.java servlet. i am passing the employee_id as a parameter in the href path itself as shown below.
    out.println("<td ><a href=\"http://localhost:7000/servlets-examples/accept_requisition.html?id="+[u]rs.getString(1)[/u]+"\" ><em>"+rs.getString(1)+"</em></a></td>");now if you see the code i am trying to pass the employee_id by attaching it to a variable id and passing it with the url, it gives me a sql exception saying no data found .
    if i pass a string say "rajiv" which i defined at the begining of code then i am able to pass it to the next servlet/html.
    the full code is as follows
    file : tstret.java
    import java.io.*;
    import java.sql.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class tstret extends HttpServlet
         PrintWriter out;
         String[] employee_identity;
         public void doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException
              try
              response.setContentType("text/html");
              out = response.getWriter();
              String session_name="SHOBA";//request.getParameter("session_name");
              out.println("<html><head><title> My Jobs </title></head>");
              out.println("<body bgColor=#ececec leftMargin=10>");
              out.println("<table align=center>");
              out.println("<tr align=center><td><img src=\"http://localhost:7000/servlets-examples/images/topbar.gif\"></td></tr>");
              out.println("<td>Jobs for : "+session_name+"</td>");
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              Connection connection = DriverManager.getConnection("jdbc:odbc:tst","scott","tiger");
              Statement statement=connection.createStatement();
              ResultSet rs= statement.executeQuery("select req_no from require_info where sent_to = " + "\'" + session_name + "\'");
    //          out.println("Jobs for : "+session_name);
              while(rs.next())
              /*     String[] get_id={"shoba","ping","ting","ving"};
                   for(int i=0;i<get_id.length;i++)
                   out.println(" <tr align=\"center\">");
              //     out.println("<td><a href=\"servlet/testhyper\" name="+rs.getString(1)+"><em>"+rs.getString(1)+"</em></a></td>");
                   out.println("<td ><a href=\"http://localhost:7000/servlets-examples/accept_requisition.html?id="+rs.getString(1)+"\" ><em>"+rs.getString(1)+"</em></a></td>");
                   out.println("</tr>");
                   out.println("<br>");
              }catch(SQLException se){out.println("sqlexception"+se);}
              catch(ClassNotFoundException ce){out.println("cnfexception"+ce);}
              out.println("</table></body></html>");
         public void doPost(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException
              doGet(request, response);
              Can some one help me and see if there is anything i missing or doing wrong.
    thanks in advance

    Try storing the id at the top of the loop, then using that for the URL and the link text, instead of calling rs.getString(1) twice:
      while(rs.next())
        String emp_id = rs.getString(1);
        out.println(" <tr align=\"center\">");
        out.println("<td ><a href=\"accept_requisition.html?id="+emp_id+"\" ><em>"+emp_id+"</em></a></td>");
        out.println("</tr>");
        out.println("<br />");
      }

  • Error while passing parameter in Oracle Jdeveloper

    Hi All,
    I was passed Crystal report viewer object  From Servlet it is Running fine but one problem in that while passing parameter from that page  to data base it is not supporting (The ok Button on page).
    can any one tell me how to find Action Button (.Jsp page)
    Because i am using .jsp  page That was made in CR4E
    in that i found only jsp code I have not get how to work Action of that button
    Also another problem while making Viewer.jsp pge ..rpt-Crystal reports--->>Create Viewer Jsp->>Insert CrysatlReport viewer API code------->>>1.Connectparameterinthat report 2.connect the crystalreportPageViewer  while makin this page  i was running on Apache tomcat Server it is not displaying Anything only Displaying Blank Browser
    Can Any one help me...
    Sincerly
    Amol

    For your first question can you please be a little more clear as to what you are referring to?  I am not familiar with an action button for the parameter pages.... what I can tell you is that we don't have any jsp code for the viewer controls, all of that is generated dynamically at runtime.  We do have a viewer SDK that you can use to set properties on the viewer; information about this can be found in the [Developer Library|https://boc.sdn.sap.com/developer/library] in the Viewer SDK documentation book.
    For your second question, I assume you are referring to generating a viewer page from a report in Crystal Reports for Eclipse.  You will need to uncomment the viewer code (for some reason when the page is generated, the viewer code has block comments surrounding it).  You will probably want to make sure the parameter code is uncommented as well. 
    In addition to this, there is a helper file called JRCHelperSample.java that contains all of the helper methods for the automatically generated viewer page.  This can be modified in whatever way you wish to suit your needs.

  • Passing Parameter using GET or Post in J2ME

    I have a problem passing parameter which has space between character to Servlet through GET or POST method. I am using HttpConnection. Which works properly whenever i sending data without space, else it shows Exception for space in URL.
    If i use trim method which is Client side scrpiting then i am not able to update the database which takes input from the J2ME midlet.
    Can any1 help me how to pass the parameter with space.

    Hi Mark,
    The "number" format relies on the formats supported by the JS
    native Number object. We don't actually do any number parsing
    ourselves in Spry. One workaround, if you need things to sort
    properly, is to have one column that is formatted european numbers,
    and one column that is actually supported by the Number object. You
    can create this custom column by using a filter:
    function DataFilter(ds, row, rowIndex)
    row["@premieNumber"] = new
    Number(row["@premieNumber"].replace(/,/, "."));
    return row;
    Regarding the Request() object and your setURL() call ... the
    3rd arg to setURL is optional, and only necessary if you are going
    to use POST, or specify some header to send. If you do use post or
    want to send some specific header, the 3rd arg just has to be an
    object with only whatever options you want to specify, you don't
    have to specify them all ... the options names exactly match the
    fields defined in a Spry.Utils.loadURL.Request object.
    We do have a utility class that gathers all of the input
    values in a form. You will find it in Spry 1.6 in SpryUtils.js. The
    name of the function to call is:
    var str = Spry.Utils.extractParamsFromForm(form, elements);
    The 2nd arg is optional, and allows you to specify what
    element values you want to retrieve. If it is not specified, it
    gets all values in the form.
    --== Kin ==--

  • Pass query to servlet through midlet

    Hi, I have a problem here. I would like to control the SQL Statement to be executed by the servlet using the mobile midlet. Like this one:
    midlet -> will call servlet with parameter statement -> servlet will execute the statement parameter passed by the midlet and will return a data result in XML -> midlet will read the XML file and retrieve the data.
    Another thing I would like to ask is how will I make the servlet to output an XML file that can be read by the midlet. If there's some tutorial on how please give me the link.
    I hope you get my point.

    I have made to retrieve data on my midlet from my servlet. The bad thing is the data sent on the midlet has html tags. How will I make the midlet to just output the data result without the tags?If you are in charge of the servlet, then have it output plain text. If you need to parse the MIDlet input first, then having the content of XML/HTML elements will allow you to print them out.
    Is this servlet used from HTML browser as well? If so, try having a separate one for mobile devices. There are plenty options to do it.
    Daniel

  • How to pass parameter to intro.jsp page ?

    Hi all,
    Anybody please tell me how to pass parameter to intro.jsp page.
    Is there any param name defined in <forward > syntax ?
    I have made following configuration in struts-config.xml file.
    I want to pass parameter to intro.jsp page
    <global-forwards>
              <forward name="invalidsession" path="/intro.jsp" redirect="true" />
    </global-forwards>
    please reply soon.
    Thanking you.

    Hi all,
    I have a similar kind of question..
    Iam trying to pass a string variable from JSP to servlet thro URL..
    Im using tomcat5
    COde:
    String fname=request.getParamter("filename");
    <jsp:forward page="/servlet/coreservlets.filedownload?name=" +fname />
    It is generating a unterminated tag error..Please help..

  • How to pass parameter in query string

    Hi Friends,
    I have a working struts app with Action classes and Servlets...now I need to pass query paramter to one of the servlets,can someone please tell me how to do that.I tried to put this code in web.xml but failed:
    <servlet>
    <servlet-name> test</servlet-name>
    <servlet-class>com.app.Test </servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>test</servlet-name>
        <url-pattern>/app/Test</url-pattern>
      </servlet-mapping>And then I tried to pass parameter as:
    http://localhost:8080/app/Test?param=value
    Please tell me guys how to accomplish this.
    Thanks in advance

    What do you mean by fails? Can you access the Servlet without the parameter? Do you get a null value when trying to retrieve the parameter?

  • Cannot pass parameter to webservice using wsdl

    cannot pass parameter to webservice using wsdl
    I write code the following:
    step 1
    -->
    DECLARE
    SERVLET_NAME VARCHAR2(32) := 'orawsv';
    BEGIN
    DBMS_XDB.deleteServletMapping(SERVLET_NAME);
    DBMS_XDB.deleteServlet(SERVLET_NAME);
    DBMS_XDB.addServlet(NAME => SERVLET_NAME,
    LANGUAGE => 'C',
    DISPNAME => 'Oracle Query Web Service',
    DESCRIPT => 'Servlet for issuing queries as a Web Service',
    SCHEMA => 'XDB');
    DBMS_XDB.addServletSecRole(SERVNAME => SERVLET_NAME,
    ROLENAME => 'XDB_WEBSERVICES',
    ROLELINK => 'XDB_WEBSERVICES');
    DBMS_XDB.addServletMapping(PATTERN => '/orawsv/*',
    NAME => SERVLET_NAME);
    END;
    step 2
    --> CREATE USER test IDENTIFIED BY test QUOTA UNLIMITED ON users;
    step 3
    --> GRANT CONNECT,CREATE TABLE, CREATE PROCEDURE TO test;
    step 4
    --> GRANT XDB_WEBSERVICES TO test
    step 5
    --> GRANT XDB_WEBSERVICES_OVER_HTTP TO test
    step 6
    --> GRANT XDB_WEBSERVICES_WITH_PUBLIC TO test
    step 7
    -->
    SELECT dbms_xdb.getftpport() FROM dual;
    SELECT dbms_xdb.gethttpport() FROM dual;
    exec dbms_xdb.setHttpPort(8080);
    exec dbms_xdb.setFtpPort(2100);
    step 8
    -- Double check
    host lsnrctl STATUS
    SET head off
    -- Valid?
    SELECT * FROM dba_registry WHERE comp_id='XDB';
    SET head ON
    connect test/test;
    CREATE OR REPLACE FUNCTION FACTORIAL_I(N PLS_INTEGER)
    RETURN PLS_INTEGER
    IS
    n_result number;
    BEGIN
    IF N > 1 THEN
    n_result := N * FACTORIAL_I(N - 1);
    RETURN(n_result);
    ELSE
    RETURN(1);
    END IF;
    END;
    WSDL Output:
    http://localhost:8080/orawsv/TEST/FACTORIAL_I?wsdl
    output picture: http://www.picza.net/show.php?id=20120429vlxdlFdvFPdvF134795
    I try pass prameter by http://localhost:8080/orawsv/TEST/FACTORIAL_I?SBINARY_INTEGER-FACTORIAL_IInput=5
    but error <ErrorNumber>ORA-31011</ErrorNumber>
    Edited by: 930927 on 29 เม.ย. 2555, 9:02 น.

    Using something like SoapUI or do it via PL/SQL as shown here: Re: Ora-31011 with a very, very simple native webservice

  • Import statement: pass parameter or variable in import statement ??

    Hi All..
    Is there a way to pass parameter or a variable to a url in the import statement..
    I'll be using a url in the import statement, the url will be having a dynamic .rtf file...something like
    <?import:http://#server#:#port#/xmlpserver/<mySubTemplate>.rtf?>
    where <mySubTemplate> is dynamic..
    I've been searching this thread for a while now and ended up close...
    Import sub template dynamically
    Thanks in Advance..

    Have you tried replacing the mySubtemplate.rtf part with a variable, or replace the entire URL using a variable? Try using the same construct from this example in the Report Designer's guide (page 7-14, 10.1.3.4).
    In Microsoft Word's Format Picture dialog box select the Web tab. Enter the
    following syntax in the Alternative text region to reference the image URL:
    url:{IMAGE_LOCATION}
    where IMAGE_LOCATION is an element from your XML file that holds the full
    URL to the image.
    You can also build a URL based on multiple elements at runtime. Just use the
    concat function to build the URL string. For example:
    url:{concat(SERVER,'/',IMAGE_DIR,'/',IMAGE_FILE)}
    where SERVER, IMAGE_DIR, and IMAGE_FILE are element names from your XML
    file that hold the values to construct the URL.
    This method can also be used with the OA_MEDIA reference as follows:
    url:{concat('${OA_MEDIA}','/',IMAGE_FILE)}

Maybe you are looking for