• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

JSP L_LAUNCHER variable is not rerecognized

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All,

I am pretty new in JSP and I have this code which does not recognize the l_launcher variable and I am not sure how to fix it. Please advise.

the code:

<%@ page contentType="text/html;charset=UTF-8" %>
<%--
/* LaunchApex.jsp */
--%>
<%@ page
import="java.io.*"
import="java.net.*"
import="java.sql.*"
import="javax.servlet.http.*"
import="java.util.Enumeration"
import="java.util.Properties"
import="java.lang.Math"
import="oracle.apps.fnd.common.VersionInfo"
import="oracle.apps.fnd.functionSecurity.Function"
import="oracle.apps.fnd.functionSecurity.RunFunction"
import="oracle.apps.fnd.common.WebAppsContext"
import="oracle.apps.fnd.common.AppsEnvironmentStore"
import="oracle.apps.fnd.common.WebRequestUtil"
import="oracle.apps.fnd.common.ResourceStore"
import="oracle.apps.fnd.security.CSS"
import="oracle.apps.fnd.common.Message"
import="oracle.jdbc.OracleConnection"
import="oracle.jdbc.OraclePreparedStatement"
import="oracle.jdbc.OracleResultSet"
%>
<%
// Session has to be validated first
WebAppsContext ctx = WebRequestUtil.validateContext(request, response);
if (ctx==null) {
return; }
String cookieName = ctx.getSessionCookieName();
boolean validSession = ctx.validateSession(cookieName);
WebRequestUtil.setClientEncoding(response, ctx);
%>
<html>
<head>
<title>Launch Apex</title>
<!-- LaunchApex.jsp -->
</head>
<body>
<%
String p_application = request.getParameter("application");
p_application = ( p_application==null ? "NONE" : p_application);
String p_page = request.getParameter("page");
p_page = ( p_page==null ? "1" : p_page);
String p_item_names = request.getParameter("item_names");
p_item_names = ( p_item_names==null ? "" : p_item_names);
String p_item_values = request.getParameter("item_values");
p_item_values = ( p_item_values==null ? "" : p_item_values);
AppsEnvironmentStore m_env = (AppsEnvironmentStore) ctx.getEnvStore();

String query = "SELECT apps_applmgr.get_apex_url FROM DUAL";

Connection conn = ctx.getJDBCConnection();

if(conn!= null){

try {
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(query);

while (rs.next())
{
String l_launcher = rs.getString(1);
} //while
rs.close();
stmt.close();

response.sendRedirect(l_launcher);
} //try
catch (Exception e) {
out.println("Exception found : ");
} //catch
}
%>
</body>
</html>

Thanks,

 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


'l_launcher' is only visible inside that while loop, so unusable outside it.

And, you really should not be using Java fragments like that in a JSP page.
Most of this should be done in a Servlet.
 
Atousa Pourdavood
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That means if I change it to :

try {
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(query);

while (rs.next())
{
String l_launcher = rs.getString(1);

rs.close();
stmt.close();

response.sendRedirect(l_launcher);
} //while
} //try

it should work?
 
Atousa Pourdavood
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What actually happened was I am using a document for linking E-business Suite to Apex and I got this JSP from the document:

but this works when E-business Suite and Apex are in the same domain and for different domain I have to call the function "get_apex_url" from the JSP and came up with this code that I uploaded but I am getting errors and don't know what to do because I am not really a JSP programmer.
Please advise.
 
Atousa Pourdavood
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now I am getting this error:

LaunchApex.java:227: error: reference to Statement is ambiguous, both interface java.sql.Statement in java.sql and class java.beans.Statement in java.beans match
Statement stmt = conn.createStatement();
^
 
Sheriff
Posts: 67756
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are new to JSP you need to know that have made a very bad start. Putting Java code into a JSP is a discredited and outdated practice that has been obsolete for 14 years. 14 years! You should be writing your JSP using a modern approach. Not one that is 14 years obsolete!

I also recommend that newcomers to JSP read these articles:
  • The Secret Life of JSPs
  • The Front Man

  •  
    Atousa Pourdavood
    Greenhorn
    Posts: 14
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thanks for the reply. Actually I am not using Java code on my daily basis and as I mentioned before, I went through the document to link from EBS to Apex and I got the code from the document and because I am not really a java programmer I tried to modify it and I got errors. I do understand when you said it's 14 years that no body uses java in jsp but I don't have much experience and I really need this code to work. could you please provide me some information how I can make this code work even in the modern environment. I appreciate your help.
     
    Bartender
    Posts: 1810
    28
    jQuery Netbeans IDE Eclipse IDE Firefox Browser MySQL Database Chrome Linux
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Atousa Pourdavood wrote:
    LaunchApex.java:227: error: reference to Statement is ambiguous, both interface java.sql.Statement in java.sql and class java.beans.Statement in java.beans match
    Statement stmt = conn.createStatement();


    Bear has already pointed out the problem with that code and I understand that you are stuck trying to fix code you don't understand, so I won't continue to flog that horse. That error means you need an import statement to tell the code what Statement class you are trying to use. My guess would be java.sql.Statement, but I say that only because that's what I use. I'm not familiar with that other package.
     
    Bartender
    Posts: 1845
    10
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Actually my understanding is that the page has imported both java.sql.Statement and java.beans.Statement classes and needs clarification as to which one you mean when you refer to "Statement"
    The 'quick hack fix' would be:
     
    J. Kevin Robbins
    Bartender
    Posts: 1810
    28
    jQuery Netbeans IDE Eclipse IDE Firefox Browser MySQL Database Chrome Linux
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I don't see an import statement for "java.beans.*" so I was puzzled by the naming collision. I assumed it was because of the "java.sql.*" wild-card import. It's best to avoid wild-card imports. I'm also puzzled why the page is importing those Oracle packages, including "oracle.jdbc.OraclePreparedStatement". I would expect that to have a Statement class which further muddies the water. It looks like the author just imported every possible package that he thought might be needed. It's rather odd code.

    e.printStackTrace(new PrintWriter(out))?? Does that really work? And catching Exception instead of SQLException?
     
    Atousa Pourdavood
    Greenhorn
    Posts: 14
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    The reality is when you need to fix the code you don't understand is really hard. I modified the code according to your suggestions and it looks like:




    It did compile but it just shows blank page with Exception found: which i belive it just goes to the catch part of the code. :(
     
    Stefan Evans
    Bartender
    Posts: 1845
    10
    • Likes 1
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    And that "exception handling" is swallow and don't print anything...
    Worst possible in my opinion.

    This code should be in a servlet/filter where it belongs. I don't see anything relevant to outputting for a JSP page here.

    However in the interests of diagnosis, replace your catch block with one that actually does something useful: like print out the error message and stack trace:




    Some questions related to what you are doing:

    Do you know what database this query should be run against?
    Does running the query against that database independently work and return a result?
    What should happen if there is no rows returned?
     
    Atousa Pourdavood
    Greenhorn
    Posts: 14
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thanks for the comment. I changed the catch part and that is the error I am getting:



    Well long story short. We are trying to link the applications we create under Oracle Apex from Oracle E-Business Suite. Here is the document I was following:
    http://www.oracle.com/technetwork/developer-tools/apex/apex-ebs-wp-cabot-consulting-169064.pdf
    Then according to the author( in another blog), we need to change the jsp that was given through this document because our Apex and EBS are not in the same domain. the jsp should be changed to what I have already given above to get the get_apex_url. and the function get_apex_url code is:


    Now, according to this error, I believe there should be something wrong with the function and the page that calls this function.
     
    Stefan Evans
    Bartender
    Posts: 1845
    10
    • Likes 1
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Ok, so here is the error message:

    Error occurred: ORA-06553: PLS-306: wrong number or types of arguments in call to 'GET_APEX_URL'
    java.sql.SQLException: ORA-06553: PLS-306: wrong number or types of arguments in call to 'GET_APEX_URL'

    Here is the function you are defining: It takes 4 parameters.


    and here is that function being called:


    That call is not passing any parameters that I can see.


    So presumably you need to pass applicat, page, item_names and item_values to the get_apex_url function.
    You have them already as variables in your code, you just need to pass them through to the SQL query.

    Something like the following:
     
    Atousa Pourdavood
    Greenhorn
    Posts: 14
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thanks for the reply. I actually passing parameters but through EBS. I created the jsp function under EBS and the HTML call is:
    LaunchApex.jsp?targetAppType=APEX&p=123:1

    the 123 is the app_ID and 1 is page number the remaining can be null.
    Now should I change the

    to

    Thanks for your help in advance.
     
    Atousa Pourdavood
    Greenhorn
    Posts: 14
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I changed it the the way you suggested but I got this error:



     
    Atousa Pourdavood
    Greenhorn
    Posts: 14
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I believe the item names and item value should be null.
     
    Atousa Pourdavood
    Greenhorn
    Posts: 14
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Well,

    I tried the code below:



    It worked perfectly. Now I don't need to pass the parameters through the jsp, I need to pass the parameters through EBS function which should be something like this in the EBS HTML call:
    LaunchApex.jsp?targetAppType=APEX&p=123:1
    How I can modify the jsp code not passing the parameters.
    I reaaly appreciate your help.
     
    Atousa Pourdavood
    Greenhorn
    Posts: 14
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thank you Stefan. It is working perfectly. I needed to change the EBS function url to make it work and the JSP is working great now. Thanks again.
     
    Atousa Pourdavood
    Greenhorn
    Posts: 14
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Is there a way instead of using :


    using:



    I need to open the page in new window. Thanks in advance.

     
    Don't get me started about those stupid light bulbs.
    reply
      Bookmark Topic Watch Topic
    • New Topic