Calling property file inside jsp in weblogic.

In JSP file, sometimes, we use the following code in the jspInit()
          <%!
          ResourceBundle resouce =null;
          public void jspInit() {
          resource = ResourceBundle.getBundle("resources");
          %>
          The resources.properties is the file to have the name value pair, which is
          easy to get a list of something.
          Can I still use properties file in my JSP in weblogic? where should I put
          properties? is it weblogic\myserver\under public_html ?
          Thank you for any help.
          li
          

Can I still use properties file in my JSP in weblogic? where should I          put
          > > properties? is it weblogic\myserver\under public_html ?
          >
          > yes, put the properties file in your java classpath.
          I mean to say, put properties file in a directory, which is in Java class
          path.
          thanks,
          -ramu
          "Ramu" <[email protected]> wrote in message
          news:3a6623c0$[email protected]..
          > "li" <[email protected]> wrote in message
          > news:3a661a8c$[email protected]..
          > > In JSP file, sometimes, we use the following code in the jspInit()
          > > <%!
          > > ResourceBundle resouce =null;
          > > public void jspInit() {
          > > resource = ResourceBundle.getBundle("resources");
          > > }
          > > %>
          > > The resources.properties is the file to have the name value pair, which
          is
          > > easy to get a list of something.
          > >
          > > Can I still use properties file in my JSP in weblogic? where should I
          put
          > > properties? is it weblogic\myserver\under public_html ?
          >
          > yes, put the properties file in your java classpath.
          >
          > -ramu
          >
          >
          >
          > >
          > >
          > > Thank you for any help.
          > >
          > > li
          > >
          > >
          > >
          > >
          >
          >
          

Similar Messages

  • How to call text file in jsp

    Hi all,
    I can call html or jsp file from jsp file, but how can I call text file in jsp, I put my text file same lever asmy jsp file it don't work!
    where I should put the text file??
    thank you

    mary,
    since you knew the file name ,when clicked in name send to server,read the file and write to servlet outputstream.
    I think this would help you.
    If anything wrong in mycode ..forums will help you further
    BufferedInputStream bis=null;
    BufferedOutputStream bos=null;
    int bytesRead=0;
    byte buff[]=new byte[1024];
    File f=new File(test.txt);
    try{
         bis= new BufferedInputStream(new FileInputStream(f));
         bytesRead=bis.read(buff,0,buff.length);
         if(bytesRead!=-1){
              // create a BufferedOutputStream from ServletOutputStream
              bos=new BufferedInputStream(response.getOutputStream());
              do{
                   bos.write(buff,0,bytesRead);
              }while((bytesRead=bis.read(buff,0,buff.length))!=-1)
    }catch(Exception e){
         ////error handling
         }

  • Call .jrxml file from jsp

    hi experts,
    i created the jasper report file, and i want to call this file through the jsp.
    plz help m.
    i written the following code but it gives the error:
    ==code==
    <%@ page import="java.sql.*" %>
    <%@ page import="java.lang.*" %>
    <%@ page import="java.lang.Object" %>
    <%@ page import="java.io.*" %>
    <%@ page import="java.util.*" %>
    <%@ page import="java.text.*" %>
    <%@ page import="net.sf.jasperreport.engine.*" %>
    <%@ page import="net.sf.jasperreport.engine.util.*" %>
    <%@ page import="net.sf.jasperreport.engine.export.*" %>
    <%@ page import="net.sf.jasperreports.engine.JasperCompileManager" %>
    <%@ page import="net.sf.jasperreports.engine.design.JRMultiClassCompiler" %>
    <%@ page import="net.sf.jasperreports.engine.JasperManager" %>
    <%@ page import="net.sf.jasperreports.engine.xml.JRXmlLoader" %>
    <%@ page import="net.sf.jasperreports.engine.JasperPrint" %>
    <%@ page import="net.sf.jasperreports.engine.JasperFillManager" %>
    <%@ page import="net.sf.jasperreports.engine.JasperExportManager" %>
    <%@ page import="net.sf.jasperreport.engine.JREmptyDataSource" %>
    <%@ page import="net.sf.jasperreports.engine.JasperReport" %>
    <%@ page import="net.sf.jasperreports.engine.design.*" %>
    <%@ page import="net.sf.jasperreports.view.JasperViewer" %>
    <%@ page import="net.sf.jasperreports.engine.JRException" %>
    <%
         String reportSource ="C:/apache-tomcat-6.0.16/webapps/ROOT/Emp/report/sample.jrxml";
         String reportDest = "C:/apache-tomcat-6.0.16/webapps/ROOT/Emp/report/sample.html";
         Map params = new HashMap();
         try
              JasperDesign jasperDesign=JRXmlLoader.load(reportSource);
              JasperManager.loadXmlDesign("sample.jrxml");
              JasperReport jasperReport =JasperCompileManager.compileReport(jasperDesign);
              JasperPrint jasperPrint =JasperFillManager.fillReport(jasperReport, params, new JREmptyDataSource());
              JasperExportManager.exportReportToHtmlFile(jasperPrint, reportDest);
              JasperViewer.viewReport(jasperPrint);
         catch (JRException ex)
              ex.printStackTrace();
    %>
    ==error==
    org.apache.jasper.JasperException: Unable to compile class for JSP:
    An error occurred at line: 31 in the jsp file: /Emp/report/rept.jsp
    JREmptyDataSource cannot be resolved to a type
    28:           JasperDesign jasperDesign=JRXmlLoader.load(reportSource);
    29:           JasperManager.loadXmlDesign("sample.jrxml");
    30:           JasperReport jasperReport =JasperCompileManager.compileReport(jasperDesign);
    31:           JasperPrint jasperPrint =JasperFillManager.fillReport(jasperReport, params, new JREmptyDataSource());
    32:           JasperExportManager.exportReportToHtmlFile(jasperPrint, reportDest);
    33:           JasperViewer.viewReport(jasperPrint);
    34:      }
    plz help m.

    Error log tells:
    JREmptyDataSource cannot be resolved to a typeYou have missed "s" in package name. Instead of:
    <%@ page import="net.sf.jasperreport.engine.JREmptyDataSource" %>do:
    <%@ page import="net.sf.jasperreports.engine.JREmptyDataSource" %>Thanks,
    Mrityunjoy

  • Accessing the text/property file inside the root context

    Hi
              I want to access the property file lying inside the root context folder
              via plain java classes using IO.
              Could you please help me out.

    Hi
    Using this.getClass().getClassLoader().getResource("config_settings");
    In order to load the properties file, uses the classpath search mechnism.
    Basically it means that java will look for your file in the classpath.
    The defualt class path of a web server is usualy the following:
    ContextName/Web-Inf/Classes;ContextName/Web-Inf/lib
    This is why it is working for you when you put your properties file under ContextName/Web-Inf/Classes, but it doesnt work when it is under ContextName/*, as this is not a part of the classpath search.
    You have 3 options:
    1.Put you properties file under the sever defulat classpath
    (ContextName/Web-Inf/Classes;ContextName/Web-Inf/lib,if it's under lib, the file has to be inside a jar file)
    2.Add ContextName/* to your server classpath ( in tomcat->setClasspath.bat file )
    3.Instead of using "this.getClass().getClassLoader().getResource("config_settings"
    read your file directly using the java.io.* library and give it the full path to the file,
    you can store the full path in web.xml file, or using getServletContext().getRealPath("") to locate the context path and read the file from there( but then you are using the Servlet API )
    Hope it helps
    all the best
    tal

  • Specify a property file inside a ear file

    Hi guys I have this myApplication.ear file.
    All the project inside the ear file are using myProperties.properties file.
    I have been told that this property file has to be inside the ear file.In websphere 7.0 ,the administrator will specify a jvm classpath like /webAS/installedApps/myApplication.ear/myProperties.properties.During runtime my code will find the property file using this class path
    I am using RAD 7.5 to generate the ear file.Can some one tell me how to achieve this.Basically my ear file has to be bundled with the property file.
    thanks
    m

    You might get better results from a RAD forum if you a havent already figured out your issue.

  • Changing values in property file inside a jar in an ear

    Hi,
    I have an application that contains EJB. The environment values needed for initial context of the ejb is kept in a .properties file. I have created an ear of the application. Inside the ear there is a jar which contains the .properties file. I need to deploy the ear to different environments. However before deploying I need some kind of script to change the values in the .properties file inside the jar in the ear.
    Can anyone provide some help/pointers about how can I achieve it (Using ANT/WLST)

    WLST does not have any capability to update a JAR.
    WLS 10.3 (still in tech preview) has the ability to override properties
    files inside the jar with an external properties file. This would allow you
    to deploy the same ear to different environments, and then only deploy a
    different properties file in the plan directory.
    <Rishi Shah> wrote in message news:[email protected]..
    Hi,
    I have an application that contains EJB. The environment values needed for
    initial context of the ejb is kept in a .properties file. I have created an
    ear of the application. Inside the ear there is a jar which contains the
    .properties file. I need to deploy the ear to different environments.
    However before deploying I need some kind of script to change the values in
    the .properties file inside the jar in the ear.
    Can anyone provide some help/pointers about how can I achieve it (Using
    ANT/WLST)

  • Calling jar file from jsp - serious problem !

    Hi there, I'm trying to call a jar from a jsp file. I need an import clause in my jsp, to the class I want to use.
    I'm using eclipse, and while i"m writing "<%= " and the begining of my class name , he autocompletes it and automatically puts an import of my class in the top of the html. It is very convenient , but the problem is that he underling the class name (in the impot: <%@page import="myClass"%>), and I get "The import myClass cannot be resolved" error.
    I got an advice to put my class in a package, since it was in a default package. I did it. But now I have 2 problems:
    1. I can't run my jar in command window: java - jar myJar.jar. in gives me: Exception in thread "main" java.lang.NoClassDefFoundError....
    2. I still get an error - "The import myClass cannot be resolved" in the jsp, although I threw the old jar (that his class I want to use was out of package), and brought a new jar after creating it.
    I hope I managed to clarify myself. I'll be thankful of any help !!!

    Hi MSoldier.
    There are two ways to do this:
    1) You use the java.lang.Runtime classes to start the java application in your JAR file, just like you would have done it from the command line. The Runtime class has three different exec() methods that can be used to run any program just like you would from the command line. Remember, using this method you will have to write everything just like if you run your Java application from the command line, incl. classpath etc. This way your Java application will be run as a separate process. When the application finishes the process is shutdown and the resources (RAM etc.) taken by it freed, just like when you shutdown any other application.
    2) You can open the JAR file yourself from inside the JSP page, look inside the META-INF file to find the main class, and then calls the main class main method. There is an example of how to do this in the Java Tutorial available from Sun under the JAR files track. Check these links :
    The Java Tutorial at Sun
    http://java.sun.com/docs/books/tutorial/
    The JAR File Tutorial at Sun
    http://java.sun.com/docs/books/tutorial/jar/index.html
    Opening JAR Files via the Java JAR File API
    http://java.sun.com/docs/books/tutorial/jar/api/index.html
    Note however, if you have just created some classes that you want to use from inside your JSP pages, and not a separate application that needs to be run separately, you should just include the JAR file with your custom classes inside the WEB-INF/lib directory. These classes are then automatically available to your JSP pages, just like the rest of the Java API.
    I hope this answers your questions,
    Kind Regards,
    Jakob Jenkov
    Software Architect
    Jenkov Development
    www.jenkov.com

  • How to call class file from jsp without creating packages

    i m using tomcat 5.5
    i stored my class file into WEB-INF\Class directory
    how to call that class file. from my jsp page.
    i got some error.
    i used package concept,that works fine.

    i m using tomcat 5.5
    i stored my class file into WEB-INF\Class directory
    how to call that class file. from my jsp page.
    i got some error.
    i used package concept,that works fine.Then use packages.
    As of Java1.4, you can no longer import classes from the default package (no package declared) into classes that are packaged.
    All Tomcat classes are in packages, including the compiled JSP.
    Therefore: Your classes need to be in a package inorder to be imported and used by the JSP.
    Why the problem? If you know it works with packages, why try not to use them?

  • Calling RDF files from JSP files

    Hi,
    I created a report file using Oracle 9i Report Builder and save it as RDF extension.After that I deployed it into the server and it's working properly.But, when I created a simple JSP file(not a report) and try to call that RDF file from this JSP file,the web browser prompts for downloading the entire RDF file.Is there any way to aviod this prompting, and make it to proper ruuning from that JSP ??
    Thanks &Regards
    Rajesh K.R

    You are in the wrong forum
    Go to Reports

  • Calling Java code inside JSP page and sending toString on object to Servlet

    Hi.
    I am trying to setup a way to make testing my application easier. Using a web-based method will work best. Here is what I am trying to accomplish:
    - Have a web page that will prompt the user to enter data, fill in text fields, make choices, etc. When done, they press the Submit button. I don't need to keep info between sessions. Just open browser, execute, view results, close browser, repeat.
    - I then want to take this data and use some Java Classes I have to create a Java object.
    - I then want to send the toString() results of this Java object to a known Java servlet. The result of the servlet's actions should be displayed as a response on the screen.
    This is what I currently have (Ignore the
    's - I don't know why they are showing up - its not important):
    Web page:
    <html>
    <head><title>TestGroup</title></head>
    <body>
    <form name=f method=post action=http://localhost:100/Servlet>
    Name: <br>
    Group: <input name=group type=text><br>
    <br>
    <input type=submit value=Submit>
    <input type=reset value=Reset>
    </form>
    </body>
    </html>The Java code in the JSP (where to put it?):
    <%
    Group g = new Group();
    g.setGroupName(request.getParameter("group"));
    String output = g.toString(); // I want this to go to the Servlet.
    %>But, now I am stuck as to how to piece these together. I have some JSP experience, but not quite like this.
    As I said, when the user presses the Submit button, I want to perform the Java code above, and have the results of the toString method sent to the Servlet, plus clear all other parameters (so they are not sent to the servlet).
    Does anyone have any advice/comments? I am open to alternative designs too, this is just the simplest one I could think of. If another JSP page is needed, that's fine too.
    Thanks.

    Hi.
    I am trying to setup a way to make testing my application easier. Using a web-based method will work best. Here is what I am trying to accomplish:
    - Have a web page that will prompt the user to enter data, fill in text fields, make choices, etc. When done, they press the Submit button. I don't need to keep info between sessions. Just open browser, execute, view results, close browser, repeat.
    - I then want to take this data and use some Java Classes I have to create a Java object.
    - I then want to send the toString() results of this Java object to a known Java servlet. The result of the servlet's actions should be displayed as a response on the screen.
    This is what I currently have (Ignore the
    's - I don't know why they are showing up - its not important):
    Web page:
    <html>
    <head><title>TestGroup</title></head>
    <body>
    <form name=f method=post action=http://localhost:100/Servlet>
    Name: <br>
    Group: <input name=group type=text><br>
    <br>
    <input type=submit value=Submit>
    <input type=reset value=Reset>
    </form>
    </body>
    </html>The Java code in the JSP (where to put it?):
    <%
    Group g = new Group();
    g.setGroupName(request.getParameter("group"));
    String output = g.toString(); // I want this to go to the Servlet.
    %>But, now I am stuck as to how to piece these together. I have some JSP experience, but not quite like this.
    As I said, when the user presses the Submit button, I want to perform the Java code above, and have the results of the toString method sent to the Servlet, plus clear all other parameters (so they are not sent to the servlet).
    Does anyone have any advice/comments? I am open to alternative designs too, this is just the simplest one I could think of. If another JSP page is needed, that's fine too.
    Thanks.

  • Cannot read Property file from JSP in a Web Module Project

    I have tried to read the properties file in two ways but am not able to read it because i cannot find the correct path of the properties file.
    1st Method :
    Properties props = new Properties();
    InputStream is =
    application.getResourceAsStream(
    "test.properties");
    if (is != null) {
    props.load(is);
    is.close();
    Enumeration keysEnum = Props.propertyNames();
    while (keysEnum.hasMoreElements()) {
    out.println(keysEnum.nextElement()) ;
    2nd Method :
    Here "com.sap.package" is the package name and "test" is the Properties file name
    ResourceBundlebundle = ResourceBundle.getBundle("com.sap.package.test");
    for (Enumeration e = bundle.getKeys(); e.hasMoreElements();)
    String key = (String) e.nextElement();
    out.print((String) e.nextElement());
    String s = bundle.getString(key);
    request.getComponentSession().putValue(key, s);
    I cannot read the properties file even when I keep in it the WEB-INF folder.

    Properties props = new Properties();
    InputStream is = this.class.getClassLoader().getResourceAsStream(/test.properties);
    if(is != null){
    props.load(is);
    Keep the test.properties in the classes folder under the web-inf folder.
    Thanks,
    Tim

  • Read a property file value and display in jsp page

    I need a solution for the below mentioned scenario,
    I want to read a value from the property file in JSP page.
    For Example, Let us have a property file called A.properties, in the file, we have a value, username = Sam.
    I want to bring this value in the jsp page.
    Please assist in this issue.
    thanks in advance.

    If you are using struts, then you have to first load the taglib like
    <%@ taglib uri="/WEB-INF/strutsresources/struts-bean.tld" prefix="bean" %>and then access the particular property like
    <bean:message key="welcome"/>Also, you have to define <message-resources> in struts-config. Though I am not into struts for year now, So, please confirm the code.

  • How can i call java class file in jsp page

    Hai,
    i wants to call .class file in jsp page.
    my class file is in C:\jsdk\bin.
    Thanks

    I'm not entirely sure what you mean by "calling a class file", but I'm going to assume that you want to do something like the following in your page:
    <%
    MyClass myClass = new MyClass();
    myClass.someMethod();
    %>etc
    If that's the case, then all you have to do is make sure that the class is in the servlet engine's classpath. You'll probably also need to include an appropriate import statement at the top of the page.
    Hope that helps.

  • Problem while executing batch file via jsp

    Scenario 1+
    I have a batch file(.bat) in which i have the following code
    mkdir d:\test\test1;
    mkdir d:\test\test2;
    mkdir d:\test\test3;
    mkdir d:\test\test4;
    mkdir d:\test\test5;
    mkdir d:\test\test6;
    mkdir d:\test\test7;
    mkdir d:\test\test8;
    mkdir d:\test\test9;
    mkdir d:\test\test10;when i double click on this or execute via cmd all the 10 directories are created successfully.
    Scenario 2+
    But when i try to execute this through a jsp using the following code,Only first 5 directories are created.Please help me in resolving the issue ASAP.Thanks in advance
    <%@page import="javax.swing.*"%>
    <%@page import="javax.swing.JFileChooser"%>
    <%@page import="java.awt.event.*"%>
    <%@page import="java.awt.*"%>
    <%@ page import="java.io.*"%>
    <%@ page import="java.util.*"%>
    <html>
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"/>
        <title>untitled2</title>
      </head>
      <body><%
            Runtime.getRuntime().exec("d:\\test.bat");
                    System.out.println("Inside Try Block");
                  %>
        hi</body>
    </html>I am using Jdeveloper.

    carrera wrote:
    Then can u suggest any other way how i can invoke a batch file from html/jsp.I think what some of the previous posters wanted to make clear is that jsps are not the place to go calling batch files. Jsp's are normally the view part and don't actually trigger these type of actions directly. Call a servlet to do non-view things...
    If all you want to do is execute an ant file, look for examples for running ant through java api. f.i. here

  • Extracting and updating files inside a JAR file... from my code

    Hi.
    I need some help in the following:
    from my code, I need to search a JAR file, open it, unzipped it, then I need to search a xml and property files inside the JAR, after that I need to modify the files and finally, my code has to save the changes and update the JAR file. All that must be from my java code.
    How can I do that? I am trying to use Runtime.getRunTime().exec().... but I am not sure that it works. Besides, I don�t know what command to include in the exec() method. Is there any way to do that?
    Thanks

    The normal reason I see for this requirement is that people want to update a properties or data file. The approach I use it that I first look for the data file in a well defined location and if I find it I use it and update it as required. If I don't fine it I create it base on a template file read from the jar file using getResourceAsSrream().
    In this way I never have to update the jar file.

Maybe you are looking for

  • Can I cancel an iTunes account?

    Hi - so I have been a long time iPhone user.  My work recently issued us iPhones (graduating from Blackberries).  IT set-up our phones and created accounts for us with our work email.  I do not wish to manage 2 accounts and 2 phones.  How can I make

  • Why can't I get Pro Tools LE to create a session on my new iMac?

    Summary I can't get Pro Tools LE to open a session on my brand new iMac. Detail Pro Tools launches but when I go to create a session it seizes up, the beach ball spins and I have to Force Quit and send yet another note to the Apple teacher. It does t

  • I found a nano on a trail. How can I find out who the owner is?

    I found a nano on a trail. How can I find out who the owner is?

  • Mouse down problem

    On a custom panel I implement MouseInputAdapter. In the mouseEntered(MouseEvent e) method, I want to do something only if the mouse button is not down. So when the cursor enters the panel and the mouseEntered(MouseEvent e) method is called I want to

  • CUA repository

    Hi All, I am currently working on SAP CUA. I wanted to know where  the data for CUA is stored in case of roles and profiles There are two tables i came across a)USRSYSACTT  (has lnaguage as one of the column) b)USRSYSACT Which table should be used to