Access Initialization Parameters using jsp

Hi All,
Now I'm learning JSP . I want to access the initialization parameters using jsp. How to do it. I used the following code , but it shows null
initparameter.jsp
    <html>
     <body>
          <h1>
               <%
                    out.println("InitParameter Checking");
                    out.println(application.getInitParameter("param1"));
               %>
          </h1>
     </body>
</html>I configured the following tags in my web.xml.
        <servlet>
          <servlet-name>initparameter</servlet-name>
          <jsp-file>/initparameter.jsp</jsp-file>
        <init-param>
                <param-name>param1</param-name>
                <param-value>value1</param-value>
            </init-param>
     </servlet>
                Help me to resolve this problem
Thanks in advance,
mahes

try overriding the jspInit method and then call getServletConfig() method and call getInitiParameter() on that ..infact the config implicit object would iachieve the same .i don't understand why it's printing null in your case .let me test and see

Similar Messages

  • Initialization Parameters for JSPs ??

    Hi All,
              Is there any way to provide Initialization Parameters for JSP ??
              If so how should it be done on Weblogic ??
              Thanx In Advance,
              Navaneeth.
              

    Hi Navaneeth ,
              If we want to provide Initialization parameters for jsp , we need to register a JSP as a servlet using the <servlet> element.
              Registering a JSP as a servlet allows you to specify the load order, initialization attributes, and security roles for a JSP, just as you would for a servlet.
              <servlet>
              <servlet-name>MainServlet</servlet-name>
              <jsp-file>/myapplication/critical.jsp</jsp-file>
              <init-param>
              <param-name>Name of the Parameter</param-name>
              <param-value>Value of the Parameter</param-value>
              </init-param>
              </servlet>
              go through the link ,you will find the documentaion on this
              http://e-docs.bea.com/wls/docs81/webapp/components.html#100437
              http://e-docs.bea.com/wls/docs81/perform/AppTuning.html
              -----Anilkumar kari

  • Error due to accessing database connection using jsp

    Hi,
    I have an error, during accessing a datbase using jsp:useBean from jsp.Urgent i need this one
    my source code is
    DbBean.java
    package SQLBean;
    import java.sql.*;
    import java.io.*;
    public class DbBean implements java.io.Serializable{
    private String dbDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
    private Connection dbCon;
    public DbBean(){
    super();
    public boolean connect() throws ClassNotFoundException,SQLException{
    Class.forName(dbDriver);
    dbCon = DriverManager.getConnection("jdbc dbc:mybean","","");
    return true;
    public void close() throws SQLException{
    dbCon.close();
    public ResultSet execSQL(String sql) throws SQLException{
    Statement s = dbCon.createStatement();
    ResultSet r = s.executeQuery(sql);
    return (r == null) ? null : r;
    public int updateSQL(String sql) throws SQLException{
    Statement s = dbCon.createStatement();
    int r = s.executeUpdate(sql);
    return (r == 0) ? 0 : r;
    database.jsp
    <HTML>
    <HEAD><TITLE>DataBase Search</TITLE></HEAD>
    <BODY>
    <%@ page language="Java" import="java.sql.*" %>
    <jsp:useBean id="db" scope="application" class="SQLBean.DbBean" />
    <jsp:setProperty name="db" property="*" />
    <center>
    <h2> Results from </h2>
    <hr>
    <br><br>
    <table>
    <%
    db.connect();
    ResultSet rs = db.execSQL("select * from employ");
    int i = db.updateSQL("UPDATE employ set fname = 'hello world' where empno='000010'");
    out.println(i);
    %>
    <%
    while(rs.next()) {
    %>
    <%= rs.getString("empno") %>
    <BR>
    <%
    %>
    <BR>
    <%
    db.close();
    %>
    Done
    </table>
    </body>
    </HTML>
    The error like this
    org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.
    error: Invalid class file format in C:\Program Files\Apache Tomcat 4.0\webapps\muthu\WEB-INF\classes\SQLBean\DbBean.class. The major.minor version '49.0' is too recent for this tool to understand.
    An error occurred at line: 7 in the jsp file: /database.jsp
    Generated servlet error:
    C:\Program Files\Apache Tomcat 4.0\work\localhost\muthu\database$jsp.java:65: Class SQLBean.DbBean not found.
    SQLBean.DbBean db = null;
    ^
    An error occurred at line: 7 in the jsp file: /database.jsp
    Generated servlet error:
    C:\Program Files\Apache Tomcat 4.0\work\localhost\muthu\database$jsp.java:68: Class SQLBean.DbBean not found.
    db= (SQLBean.DbBean)
    ^
    An error occurred at line: 7 in the jsp file: /database.jsp
    Generated servlet error:
    C:\Program Files\Apache Tomcat 4.0\work\localhost\muthu\database$jsp.java:73: Class SQLBean.DbBean not found.
    db = (SQLBean.DbBean) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "SQLBean.DbBean");
    ^
    4 errors, 1 warning
    Anybody help me?
    Thanx in advance

    Your code is ok . The problem is in java version witch you use to compile the DbBean class . I think you are using java 1.5 try to change to 1.4 compile and run again should help .

  • Problem with accessing init parameters from JSP file

    Hi,
    I have my init parameters and Jsp configured in web.xml
    <servlet>
              <servlet-name>TestJsp</servlet-name>
              <jsp-file>/Test.jsp</jsp-file>
              <init-param>
                   <param-name>username</param-name>
                   <param-value>Balboa</param-value>
              </init-param>
    </servlet> How do I access 'username' field from JSP file.
    Kindly help.
    Thanks.

    you can do this in the jsp
    <%=config.getInitParameter("username")%>or do it in the jspInit method in the jsp:
    <%!  String userName = null; 
      public void jspInit() {   
        ServletConfig config = getServletConfig();   
        userName   = config.getInitParameter("userName ");  
    %>
    Hello <%=userName%>

  • Using JSP to connect to an Access Database

    I need help on using JSP to connect to an Access database.
    This is the code I currently have connecting to a mySQL DB. I need to change it to connect to an Access DB. The reason I am switching DB's is because mySQL is no longer going to be carried by my host.
    Here is the code:
    <html>
    <head>
    <basefont face="Arial">
    </head>
    <body>
    <%@ page language="java" import="java.sql.*" %>
    <%!
    // define variables
    String UId;
    String FName;
    String LName;
    // define database parameters
    String host="localhost";
    String user="us867";
    String pass="jsf84d";
    String db="db876";
    String conn;
    %>
    <table border="2" cellspacing="2" cellpadding="5">
    <tr>
    <td><b>Owner</b></td>
    <td><b>First name</b></td>
    <td><b>Last name</b></td>
    </tr>
    <%
    Class.forName("org.gjt.mm.mysql.Driver");
    // create connection string
    conn = "jdbc:mysql://" + host + "/" + db + "?user=" + user + "&password=" +
    pass;
    // pass database parameters to JDBC driver
    Connection Conn = DriverManager.getConnection(conn);
    // query statement
    Statement SQLStatement = Conn.createStatement();
    // generate query
    String Query = "SELECT uid, fname, lname FROM abook";
    // get result
    ResultSet SQLResult = SQLStatement.executeQuery(Query);
         while(SQLResult.next())
              UId = SQLResult.getString("uid");
              FName = SQLResult.getString("fname");
              LName = SQLResult.getString("lname");
              out.println("<tr><td>" + UId + "</td><td>" + FName + "</td><td>" + LName
    + "</td></tr>");
    // close connection
    SQLResult.close();
    SQLStatement.close();
    Conn.close();
    %>
    </table>
    </body>
    </html>
    Thank You,
    Josh

    <%@ page language="java"%>
    <html>
    <head>
    <title>
    First Bean
    </title>
    <%@ page import="java.sql.*" %>
    </head>
    <body>
    <p>
    <%!
    Connection con;
    Statement st;
    ResultSet rs;
    String userid;
    String password;
    %>
    <%!public void db(JspWriter out)
    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con=DriverManager.getConnection("jdbc:odbc:phani");
    catch(Exception e){}
    try{
    st=con.createStatement();
    rs=st.executeQuery("SELECT * FROM login");
    while(rs.next())
    userid=rs.getString("userid");
    password=rs.getString("password");
    out.println(userid);
    out.println("</br>");
    out.println(password);
         out.println("</br>");     
    }catch(Exception e){}
    try{
    con.close();
    }catch(Exception e){}
    %>
    <%db(out);%>
    </p>
    </body>
    </html>
    phani is dsn name
    login is table name
    Good luck
    phani

  • UNABLE TO ACCESS SECURED EJB USING IIOP FROM JSP

    Following codes does not work with IIOP when called from jsp returns an
    com.sap.engine.services.iiop.CORBA.CORBAObject:com.sap.engine.services.iiop.server.portable.Delegate_1_1@8312b1 step2 RemoteException occurred in server thread; nested exception is: java.rmi.RemoteException: com.sap.engine.services.ejb.exceptions.BaseRemoteException: User Guest does not have access to method create(). at
    Following codes does not work with IIOP when called from a fat client returns an
    org.omg.CORBA.UNKNOWN:   vmcid: 0x0  minor code: 0 completed: Maybe
            at com.sun.corba.se.internal.core.UEInfoServiceContext.<init>(UEInfoServ
    iceContext.java:33)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
    orAccessorImpl.java:39)
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
    onstructorAccessorImpl.java:27)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
            at com.sun.corba.se.internal.core.ServiceContextData.makeServiceContext(
    Properties p = new Properties();
    p.put(Context.INITIAL_CONTEXT_FACTORY,
    "com.sun.jndi.cosnaming.CNCtxFactory");
    p.put(Context.PROVIDER_URL, "iiop://hostname:50007");
    p.put(Context.SECURITY_PRINCIPAL, "User");
    p.put(Context.SECURITY_CREDENTIALS, "pass");
    I have add java option to add IIOP filer
    -Dorg.omg.PortableInterceptor.ORBInitializerClass.com.sap.engine.services.iiop.csiv2.interceptors.SecurityInitializer
    Solution Required: Could you please detail me what steps in need to perform in order for me to access secure ejb using iiop protocol.
    FYI -- How ever ejb security works with P4 protocol, If required i can send you the test case ear.
    Thanks
    Vijay
    Following are the server side logs
    java.rmi.RemoteException: com.sap.engine.services.ejb.exceptions.BaseRemoteException: User Guest does not have access to method create().
         at test.TestEJBHomeImpl0.create(TestEJBHomeImpl0.java:91)
         at test._TestEJBHome_Stub.create(_TestEJBHome_Stub.java:214)
         at jsp_testIIOP1199698887113._jspService(jsp_testIIOP1199698887113.java:33)
         at com.sap.engine.services.servlets_jsp.server.jsp.JspBase.service(JspBase.java:112)
         at com.sap.engine.services.servlets_jsp.server.servlet.JSPServlet.service(JSPServlet.java:544)
         at com.sap.engine.services.servlets_jsp.server.servlet.JSPServlet.service(JSPServlet.java:186)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:390)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:264)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:347)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:325)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:887)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:241)
         at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
         at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
         at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
    Caused by: com.sap.engine.services.security.exceptions.BaseSecurityException: Caller not authorized.
         at com.sap.engine.services.security.resource.ResourceHandleImpl.checkPermission(ResourceHandleImpl.java:608)
         at com.sap.engine.services.security.resource.ResourceHandleImpl.checkPermission(ResourceHandleImpl.java:505)
         at com.sap.engine.services.security.resource.ResourceContextImpl.checkPermission(ResourceContextImpl.java:45)
         at test.TestEJBHomeImpl0.create(TestEJBHomeImpl0.java:89)
         ... 20 more
    ; nested exception is:
         java.lang.SecurityException: com.sap.engine.services.security.exceptions.BaseSecurityException: Caller not authorized.
         at com.sap.engine.services.security.resource.ResourceHandleImpl.checkPermission(ResourceHandleImpl.java:608)
         at com.sap.engine.services.security.resource.ResourceHandleImpl.checkPermission(ResourceHandleImpl.java:505)
         at com.sap.engine.services.security.resource.ResourceContextImpl.checkPermission(ResourceContextImpl.java:45)
         at test.TestEJBHomeImpl0.create(TestEJBHomeImpl0.java:89)
         at test._TestEJBHome_Stub.create(_TestEJBHome_Stub.java:214)
         at jsp_testIIOP1199698887113._jspService(jsp_testIIOP1199698887113.java:33)
         at com.sap.engine.services.servlets_jsp.server.jsp.JspBase.service(JspBase.java:112)
         at com.sap.engine.services.servlets_jsp.server.servlet.JSPServlet.service(JSPServlet.java:544)
         at com.sap.engine.services.servlets_jsp.server.servlet.JSPServlet.service(JSPServlet.java:186)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:390)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:264)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:347)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:325)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:887)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:241)
         at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
         at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
         at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)

    That's the code that you need to execute but you should
    probably encapsulate that code in Custom Action.
    Orion has a EJB Tag Library that is free to distribute that
    does all that stuff you just set some attributes.
    Go to their site and look at their Tag Libraries.
    Also look for other Tag Libraries Freely Available for EJB Access.

  • Uploading images in access database using jsp

    Hi, am using jsp with access database and want to upload as in a profile picture for any profile on the site[i mean depending on the user's convenience] ..
    I just have a code which helps select the image from the client's machine n gets its address..but then how to use it in a form or something so that it can be submitted and inserted in the database?
    Any idea? I d prefer not using servelet.. but if it just cannot be done without servelet then ok can suggest with that too.
    Here is the code of Browsing to obtain the picture:
    <form name=uploadForm action="uploadpic.jsp" method=post enctype="multipart/form-data" >     <input type="file" > <input type="submit" name="submit"  />     </form>

    silversurface wrote:
    Hi, am using jsp with access database and want to upload as in a profile picture for any profile on the site[i mean depending on the user's convenience] ..
    bad. Don't put business logic in JSP, and that includes accessing databases.
    Any idea? I d prefer not using servelet.. but if it just cannot be done without servelet then ok can suggest with that too.
    Don't put business logic in JSP. That's what servlets are for (and EJB).

  • How i can create tables(database) in ms-access using jsp

    i want to create tables by using jsp in ms-access .user can only enter
    table name ,how many table fields ,constraints etc

    You'll get better luck if you post this JDeveloper/ADF/JSF question to the JDeveloper forum.
    -steve-

  • Need sysdba access to edit initialization parameters

    When I log into enterprise manager, go to database, then initialization parameters..
    it says 'You are not logged on with sysdba privilege'
    my preferences - credentials has sys and password in the sysdba fields..
    what needs to be done

    What you need to do is logout, and log back in with a user that has sysdba privileges.
    After you click on Logout, you will see the options:
    - Log out of Database: database_name
    - Display database login page after logout
    Use this option to reconnect to the database as a different user
    Log out of Enterprise Manager and all other targets
    (Logged in As YOURUSER)
    Select - Log out of Database and Display database login page after logout.
    You will then get the option to connect as sysdba. Change Connect as "Normal" to SYSDBA.
    HTH

  • Cannot access VARCHAR2s on Oracle 9i using JSP/JDBC

    After upgrading from Oracle 8.1.7 to Oracle 9, I get an
    exception when using JSP/JDBC to read data from columns
    containing VARCHAR2s. I can successfully read columns
    containing BLOBs, CLOBs, NUMBERs, and RAWs.
    I still can select VARCHAR2 columns by using SQL*Plus so the
    problem is with JDBC and not the database.
    I get the following exception message:
    java.sql.SQLException: ORA-00600: internal error code,
    arguments: [ttcgcshnd-1], [0], [], [], [], [], [], []
    The following code that worked on Oracle 8 fails to execute
    properly on Oracle 9:
    OracleResultSet rs = null;
    String sql = "select name from users where id > 100";
    rs = (OracleResultSet)s.executeQuery(sql);
    I'm using Windows 2000, Tomcat 3.2.2, Java 1.3, and the latest
    version of OracleJSP.
    Has anyone run into this problem?
    I've also entered this same query on the Java-SQLJ/JDBC
    discussion fourm.

    I4ve installed Oracle 9i on RedHat 7.2.
    We develop with WebObjects and JBuilder.
    When i try to connect to the database via the EOModeller (JDBC) i got the same error:
    Stack Trace:
    JDBCAdaptorException: ORA-00600: Interner Fehlercode, Argumente: [ttcgcshnd-1], [0], [], [], [], [], [], []
    Then, i started creating and droping tables in the 9i Database >> it works fine.
    Can someone give an solution for this problem??

  • Using jsp in webi(BO).

    How can i use Jsp in BusinessObjects Webintelligence tool and for what purpose i can use jsp coding to create reports?
    Thanks in advance.
    Rp

    Hi Meghna,
    Did you try this query in repository explorer?
    This seems very complex query and as per error some mandatory initialization is missing
    I guess each valuation have their own identifier, which you also have to pass as parameter.
    Give a try in Repository explorer with all required parameters.
    Regard
    Sunil

  • File upload and download using jsp/servlets

    How to upload any file to the server using jsp/servlets. . Help me out

    You can also try the Jenkov HTTP Multipart File Upload. It's a servlet filter that is easy to add to your web-project. After adding it, you can access both request parameters and the uploaded files easily. It's more transparent than Apache Commons File Upload. There is sufficient documentation to get you started, and there is a forum if you have any questions.
    Jenkov HTTP Multipart File Upload is available under the Apache license, meaning its free to use.

  • Accessing Portal session in JSP

    Hi
    How can I access session parameters set via wwsto_api_session in jsp portlet.
    Regards,
    Vikas.

    Hi,
    If you want to access the procedures in wwsto_api_session package from a JSP, you can use JDBC calls.
    Otherwise, if you need the Httpsession specific information you can use the ProviderSession class in JPDK. You can obtain an instance of this using PortletRenderRequest object.
    thanks,
    Sriram

  • Can I access URL parameters?

    Is it possible to access URL parameters from a WebStart application?
    Example:
    http://www.domain.com/example.jnlp?parameter1=43
    I would like to initialize my JWS app using the information given to me in parameter1.
    Is this possible? I believe that this would be very powerful.
    Thanks.

    If your www.domain.com/example.jnlp is a CGI script or servlet that returns a .jnlp file with
      <application-desc>
        <argument>43</argument>
    </application-desc>and you retrieve that parameter from args[1], it might work.
    Regards,
    Marc

  • How to Access User Parameters in Web Reports

    Hi Friends,
    I am working on Oracle Reports 9i. I am able to access user parameters in Paper Layout by using :user_param1 or &User_param1. But when i am using the same to access user parameters in web source i am not able to access these.
    Actually inside a report i want to create a hyperlink for executing an another report. In this hyperlink i need to pass some user parameters too. But when i am using web source i am unable to access user parameters. Can Somebosy help me on that.
    Thanka in advance
    Regards
    Kamal
    [email protected]

    Hi Kamal,
    For you requirement, the following chapter in the 'Building Reports manual' should help you. Go through the chapter-" Building a Simple Parameter Form for a JSP-based Web Report'. This will help you on how to create a parameterform and to run the report based on the parameter value.
    You can download this manual from the location http://download.oracle.com/docs/html/B10602_01/toc.htm.
    Thanks,
    Vidya

Maybe you are looking for

  • Should I Use a Dynamic "Get" Function?

    So let's say I have a table called "Book", and it has the columns "ID, Name, Author, ISBN" I'm wondering what the Pros and Cons would be to creating a function to get books by any attribute using one function: <cffunction name="GetBook"> <cfargument

  • Using Shared Memory in LabVIEW

    I'm trying to use shared memory with LabVIEW. Can I use it, a DLL in C with LabWIEW for use shared Memory?

  • Dead on arrival Iphone 4S number 4

    I wonder if anyone else experience the problems that I am having with trying to get a 100% working and scratchless Iphone 4S, so here goes. First Iphone 4S delivered in october (as soon as it was possible in the Netherlands). After 2 weeks I noticed

  • Preview - crop error after saving, and field lock-out

    Filling out PDF's of my taxes, I get two consistent errors: 1. When I try to save my work, it crops the page, leaving white space to the left and below, and cutting off the page to the right and above 2. I loose the pre-set fields, and can no longer

  • T42 - Vista upgrade - very slow laptop - help please

    Hi I have installed Vista Home Premium on my T42 (previously had XP Pro) and it is now very, very slow.  Also it seems to have erased everything IBM - ie -Access IBM button not working. Type 2373 - f1G, HD 40mb, Memory 500kb. Do I need to increase ha