Injection Problem in a JSP

Hello,
I created an enterprise application (with Netbeans 5.5 20060310) with Entity beans and stateless session bean (EJB3) -> everything seems fine, the tables are created when I deploy (on latest Glassfih).
Then I created in the webmodule a small JSP to test my session bean.
I wanted to use dependency injection so I added
<%!
   @EJB UserLocal userManager;  
%>to the page where UserLocal is the local business interface of my session bean.
I manage to display the JSP page correctly but the userManager is null.
Do you have any idea of what is wrong ?
I do not understand the injection mechanism... do you have any reference?
Also what would be the jndi name of my bean (it seems to me that it depends in the AS...) if I have no other choice but use a JNDI lookup ?
Many thanks,
Sebastien

When trying to inject the EJB in a servlet I obtain the following exception:
com.sun.enterprise.InjectionException: Exception attempting to inject Unresolved Ejb-Ref
com.diviosoft.sp.web.userServlet/userManager@jndi: com.diviosoft.sp.logic.UserLocal@[email protected]@Session@nullinto class com.diviosoft.sp.web.userServletI tried to give a name to the EJB and use it when injecting, without success
... any hint appreciated
Sebsatien

Similar Messages

  • SQL injection problem

    hi
    How can we solve SQL injection problem in JDBC ?
    this means if we have a form with text field and the user must enter a number say 4 , instead he entered "4 or true" this will concatenated with the SQL query and return all records because of "or true"....
    is there any solutions ?
    i tried PreparedStatment and it words but not alwayes
    good luck

    i clearfied this in my first post
    if u didnt got what i mean u can google it
    http://www.google.com
    thanksYou didn't gently provide keywords, like I always do, so I cannot learn from you.
    Well, with a "reproduceable example" I mean that you have to post a short but complete working code snippet which reproduces the problem. So that we can copy'n'paste it in our environment here and test/debug it ourself and then eventually confirm the SQL injection.

  • Problem in connecting JSP with Oracle 9i.

    Hi,
    I am having problem in connecting JSP with Oracle 9i.
    I am using windows XP and my JDK version is 1.4. For executing JSP I am using
    "jakarta-tomcat-5.5.4-preconfigured". My database name is global.
    I have set java_home, j2ee_home, oracle_home, path, classpath as follows:
    j2ee_home=c:\sun\appserver
    java_home=c:\sun\appserver\jdk
    oracle_home=C:\oracle\ora92
    path=C:\Sun\AppServer\bin;C:\Sun\AppServer\jdk\bin;C:\oracle\ora92\bin
    classpath=C:\Sun\AppServer\lib\j2ee.jar;C:\oracle\ora92\jdbc\lib\ojdbc14.jar;C:\oracle\ora92\jdbc\lib\nls_charse
    t12.zip
    My code is as follows:
    <%@ page language="java" %>
    <%@ page import ="java.sql.*"%>
    <%
    try
    DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
    Connection conn = DriverManager.getConnection ("jdbc:oracle:oci8:@global", "scott", "tiger");
    catch(SQLException e)
    out.println(""+e);
    out.println("Connected");
    %>
    I tried other program:
    <%@ page language="java" %>
    <%@ page import ="java.sql.*"%>
    <%
    Class.forName("oracle.jdbc.driver.OracleDriver");
    Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:global","scott","tiger");
    out.println("Connected");
    %>
    I am getting following error:
    exception
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: 5 in the jsp file: /jsp/oracle.jsp
    Generated servlet error:
    oracle.jdbc.OracleDriver cannot be resolved or is not a type
         org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
         org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
         org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:389)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:288)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:556)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:296)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    Thanking you in advance,
    Anurag

    maneesh108 wrote:
    hi this is maneesh1) Read the thread it has been answered.
    2) The thread is very old. Don't resurrect old threads.
    I'm locking this zombie thread.
    Kaj

  • Problem in Struts JSP

    Hi All,
    I have a problem in the JSP where I am using two select list boxes for displaying two lists of size 4, I can transfer the values from one list box to another using buttons. The html part is as mentioned below:
    <td colSpan="2">
    <html:radio property="types" value="all" onclick="greyOutTypes(true);fb_MoveAllOptions(transSearchQueryForm.availableTypes, transSearchQueryForm.selectedTypes);displayVal()"/><bean:message key="label.report.allTypes" />
    <bean:message key="label.report.or"/>
    <html:radio property="types" value="select" onclick="greyOutTypes(false);fb_MoveAllOptions(transSearchQueryForm.selectedTypes, transSearchQueryForm.availableTypes);displayVal()"/>
    <bean:message key="label.report.selectTypes" />
    </td>
    </tr>
    <tr>
    <td>
    <br>
    </td>
    <td colSpan="4">
    <table cellpadding="0" cellspacing="2" border="0">
    <tr>
    <td colspan=3>
    <bean:message key="label.report.availableTypes"/>
    </td>
    <td>
    <bean:message key="label.report.selectedTypes"/>
    </td>
    </tr>
    <tr>
    <td>
    <bean:define name="transSearchQueryForm" id="availableTypesCollection" property="availableTypesTM" />
    <html:select size="4" property="availableTypes" multiple="true" styleClass="lists" >
    <html:options collection="availableTypesCollection" property="key" labelProperty="value" />
    </html:select>
    </td>
    <td vAlign=center align=middle>
    <p>
    <input type="button" name="btRemoveGroup" class="smallbutton" value="<" onclick="javascript:fb_SelectBoxMoveSelectedOptions(transSearchQueryForm.selectedTypes, transSearchQueryForm.availableTypes);displayVal()">
    <br>
    <input type="button" name="btRemoveAllGroups" class="smallbutton" value="<<" onclick="javascript:fb_MoveAllOptions(transSearchQueryForm.selectedTypes, transSearchQueryForm.availableTypes);displayVal()">
    </p>
    </td>
    <td vAlign=center align=middle>
    <p>
    <input type="button" name="btAddGroup" class="smallbutton" value=">" onclick="javascript:fb_SelectBoxMoveSelectedOptions(transSearchQueryForm.availableTypes, transSearchQueryForm.selectedTypes);displayVal()">
    <br>
    <input type="button" name="btAddAllGroups" class="smallbutton" value=">>" onclick="javascript:fb_MoveAllOptions(transSearchQueryForm.availableTypes, transSearchQueryForm.selectedTypes);displayVal()">
    </p>
    </td>
    <td>
    <bean:define name="transSearchQueryForm" id="selectedTypesCollection" property="selectedTypesTM" />
    <html:select property="selectedTypes" multiple="true" size="4" styleClass="lists" >
    <html:options collection="selectedTypesCollection" property="key" labelProperty="value" />
    </html:select>
    </td>
    </tr>
    </table>
    </td>
    </tr>
    The transfer of values works fine when we select one or more values by individually selecting them. But this fails to work when we do a move all or we click on the Select radio button which eventually does a move all.
    After analyzing we found that when we do a move all then the form bean does not get updated with the changes made by the user; like suppose we move all from the Select list to Available list then the availableTypes array (which is associated with the Select for Available Types) show all the types moved to it which is correct but the selectedTypes array (which is associated with the Select for Select Types) also shows all the types in the form bean so when the JSP is reloaded then both the lists boxes show the same entries (all the entries on either side), thus duplicating each entry and causing an error.
    The same work absolutely correctly when we manually select one or more entries from either of the list boxes. Meaning both the form bean arrays reflect what the user has selected on the screen.
    The methods called on click of the buttons are clearly setting and removing entries selected from the two arrays. We put alerts in the JSP to see the changes in the arrays and they reflect correct values. But once the control has been transferred to the java classes we view the form bean values of the same two arrays which show different values.
    Please let me know how I can make the changes of the user reflect in the form bean somehow!
    Thanks,
    Regards,
    Abhishek Arora

    Hi,
    I have similar code, and i have used java script, i hope it is usefull and it is quite simple in fact very simple
    <html>
    <head>
         <script language="javascript">
              function moveDualList(leftlist,rightlist)
                   if(leftlist.selectedIndex==-1)
                        alert("Nothing Slected To Transfer");
                   else
                        newDestList = new Array( rightlist.options.length );
                        var len = 0;
                        for( len = 0; len < rightlist.options.length; len++ )
                             newDestList[ len ] = new Option(rightlist.options[ len ].text,rightlist.options[ len ].value,rightlist.options[ len ].defaultSelected, rightlist.options[ len ].selected);
                             var styletextinlist = rightlist.options[len].style.cssText;
                             newDestList[ len ].style.cssText = styletextinlist;
                        for(var i=0;i<leftlist.options.length;i++)
                             if((leftlist.options!=null) && (leftlist.options[i].selected==true))
                                  newDestList[ len ] = new Option(leftlist.options[i].text, leftlist.options[i].value, leftlist.options[i].defaultSelected, leftlist.options[i].selected);
                                  var styletextinlist = leftlist.options[i].style.cssText;
                                  newDestList[ len ].style.cssText = styletextinlist;                              
                                  len++;
                        for ( var j = 0; j < newDestList.length; j++ )
                        if ( newDestList[ j ] != null )
                             rightlist.options[ j ] = newDestList[ j ];                    
                        for( var i = leftlist.length -1; i >= 0 ; i--)
                        if ( leftlist.options[i] != null && ( leftlist.options[i].selected == true))
                             leftlist.options[i]=null;                                                  
         </script>
    </head>
         <body>
              <center>
                   <form name="coolform">     
                   <table border="0">
                        <tr>
                             <td rowspan="2">
                                  <select size="10" name="leftlist" multiple>
                                       <option style = "color:RED">One
                                       <option style = "color:BLUE">Two
                                       <option style = "color:GREEN">Three
                                  </select>
                             </td>
                             <td align="center"><input type="button" value="Add>>" name = "added" onClick="moveDualList(document.coolform.leftlist,document.coolform.rightlist)"></td>
                             <td rowspan="2">
                                  <select name="rightlist" size="10" multiple>                                   
                                  </select>
                             </td>
                        </tr>
                        <tr>     
                             <td><input type="button" value="Rem<<" onClick="moveDualList(document.coolform.rightlist,document.coolform.leftlist)"></td>
                        </tr>
                   </table>
                   </form>
              </center>
         </body>     
    </html>

  • Problems placing compiled jsp in the right directory

    I have problems placing compiled jsp in the right directory.
              - My document root is weblogic/myserver/public_html
              - My jsp's are placed in weblogic/myserver/public_html/ram/jsp.
              - My folder for placing compiled jsp is in weblogic/myserver/compiled_jsp.
              - When weblogic compiles my jsp it places them in
              weblogic/myserver/compiled_jsp/jsp_servlet/_ram/_jsp
              Now I want to compile ram1.jsp and place it in above directory. I tried the
              following but it does not place class correct.
              1: java weblogic.jspc -d C:\weblogic\myserver\compiled_jsp ram1.jsp
              **** Places the class in weblogic/myserver/compiled_jsp/jsp_servlet
              2: java weblogic.jspc -d
              C:\weblogic\myserver\compiled_jsp\jsp_servlet\_ram\_jsp ram1.jsp
              C:\weblogic\myserver\compiled_jsp\jsp_servlet\_ram\_jsp\jsp_servlet\_ram1.cl
              ass
              What am I doing wrong ?
              cheers Per
              

              I would try this...
              cd public_html
              java weblogic.jspc -prefix compiled_jsp ram/jsp/ram1.jsp
              I'm not sure if -prefix is the exact option - something like that - maybe package_prefix.
              As always, things work better/easier when you leave things at the default value
              (jsp_servlet).
              Mike
              "Per Lovdinger" <[email protected]> wrote:
              >I have problems placing compiled jsp in the right directory.
              >
              >- My document root is weblogic/myserver/public_html
              >- My jsp's are placed in weblogic/myserver/public_html/ram/jsp.
              >- My folder for placing compiled jsp is in weblogic/myserver/compiled_jsp.
              >
              >- When weblogic compiles my jsp it places them in
              >weblogic/myserver/compiled_jsp/jsp_servlet/_ram/_jsp
              >
              >Now I want to compile ram1.jsp and place it in above directory. I tried
              >the
              >following but it does not place class correct.
              >
              >1: java weblogic.jspc -d C:\weblogic\myserver\compiled_jsp ram1.jsp
              >**** Places the class in weblogic/myserver/compiled_jsp/jsp_servlet
              >
              >2: java weblogic.jspc -d
              >C:\weblogic\myserver\compiled_jsp\jsp_servlet\_ram\_jsp ram1.jsp
              >****
              >C:\weblogic\myserver\compiled_jsp\jsp_servlet\_ram\_jsp\jsp_servlet\_ram1.cl
              >ass
              >
              >What am I doing wrong ?
              >
              >cheers Per
              >
              >
              

  • Problem with login jsp

    I made a login.jsp with the help of a bean. the bean holds a string[] as a property where it stores user and pass, then those values are checked in my database, and a boolean bean property is set to true. The problem is I want to do an if statement in my JSP using that boolean, but I can't seem to get the jsp working, can anyone help me?
    I'm doing
    <%if (<jsp:getProperty name="auth" property="truth"/>) do something else something else%>
    I've also tried
    <%! boolean it = <jsp:getProperty name="auth" property="truth"/> %>
    <%if (it) do something else something else%>
    both give me compile errors.

    <jsp:getProperty name="auth" property="truth"/> is roughly equivalent to
    <% out.print(your_bean.getTruth()); %> or <%=your_bean.getTruth()%>
    Once you understand this, you'll see why your code cannot possibly work...
    Below is a simple solution to your problem.
    <jsp:useBean   class="YourBean"  id="auth"  etc.. >
    <% if auth.getTruth() {
          something; // don-t forget the semi-colon
       else {
          some other thing; // ditto
    %>If you don't want any java code inside your jsp, consult the JSTL tag lib to construct an xml-like if-else statement.

  • Problem launching a jsp page with eclipse and tomcat

    Hi,
    I have just started using eclipse and tomcat for creating dynamic web pages. I tried to launch a jsp page after starting the tomcat server with the URL: http://locahost:8080/HelloWorld/, an error page was displayed as below:
    HTTP Status 404 -/
    type Status report
    message /_
    description The requested resource (-) is not available
    Apache Tomcat/5.5.17
    I didn't get any error at the console and when i just typed http://localhost, a pop up menu saying that the connection was refused when attempting to contact localhost.
    I'm not sure what is the problem here. Could it be the permssion to the localhost is not granted by the system as the eclipse IDE is running using linux?
    Hope someone can help.
    Thanks.

    http://www-128.ibm.com/developerworks/library/os-ectom/

  • Problem with javascript jsp

    Hi,
    I am using following htl in my jsp.
    <INPUT type=CHECKBOX name='markets' value='911|6' >
    I am using the following javascript in on submit event
    alert(document.form.markets.length );But i am getting "undefined" in my alert box.However if there are more such checkboxes named market...i am getting the length as output.
    what may be the problem?
    Thanks
    Vivek

    i tried this and its working fine:
    alert(document.forms[0].markets.length );
    <form>
    <INPUT type=CHECKBOX name='markets' value='911|6' >
    <INPUT type=CHECKBOX name='markets' value='911|6' >
    <INPUT type=CHECKBOX name='markets' value='911|6' >
    <INPUT type=CHECKBOX name='markets' value='911|6' >
    <INPUT type=CHECKBOX name='markets' value='911|6' >
    <INPUT type=CHECKBOX name='markets' value='911|6' >
    </form>

  • Dependency Injection Problem in EJB 3.0

    Hello.
    I've been trying to get an example of java dependency injection working in JBoss 4.0.5.GA. I've installed it with EJB 3.0 support.
    The problem is that if I try to use the injected resource, I get a null pointer exception.
    The example I'm trying is a very short and simple one. Shouldn't be hard to figure out what is going wrong. Here it goes:
    [root]\src\hello\MessageServlet.java:
    package hello;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.util.List;
    import java.util.ListIterator;
    import javax.naming.InitialContext;
    import javax.annotation.*;
    public class MessageServlet extends HttpServlet {
         @Resource (mappedName="java:/DefaultDS")
         javax.sql.DataSource ejb30DB;
         public void init () throws ServletException {
         public void service(HttpServletRequest request, HttpServletResponse response)
                   throws IOException, ServletException {
              boolean injectedLookingGood = false;
              boolean notInjectedLookingGood = false;
              try {
                   java.sql.Connection conn = ejb30DB.getConnection();
                   conn.close();
                   injectedLookingGood = true;
              } catch(Exception e) {
                   e.printStackTrace();
              try {
                   InitialContext ic = new InitialContext();
                   javax.sql.DataSource ds = (javax.sql.DataSource)ic.lookup("java:/DefaultDS");
                   java.sql.Connection conn = ds.getConnection();
                   conn.close();
                   notInjectedLookingGood = true;
              } catch(Exception e) {
                   e.printStackTrace();
              response.setContentType("text/html");
              ServletOutputStream out = response.getOutputStream();
              out.println("<html>");
              out.println("<head><title>Hello World</title></head>");
              out.println("<body>");
              out.println("<h1>Hello World</h1>");
              out.println("<form action=\"HelloWorld\" method=\"get\">");
              out.print("Injected DataSource is looking ");
              if(injectedLookingGood) {
                   out.println("good <br>");
              else {
                   out.println("bad <br>");
              out.print("Not-Injected DataSource is looking ");
              if(notInjectedLookingGood) {
                   out.println("good <br/>");
              else {
                   out.println("bad <br/>");
              out.println("<input type=\"submit\" value=\"Test Some More\">");
              out.println("</form>");
              out.println("</body>");
              out.println("</html>");
    [root]\etc\META-INF\web.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
    "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
    <web-app>
    <display-name>HelloWorldWAR</display-name>
    <servlet>
    <display-name>HelloWorld</display-name>
    <servlet-name>HelloWorldServlet</servlet-name>
    <servlet-class>hello.MessageServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>HelloWorldServlet</servlet-name>
    <url-pattern>/servlet/HelloWorld</url-pattern>
    </servlet-mapping>
    </web-app>
    [root]\etc\META-INF\application.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <application xmlns="http://java.sun.com/xml/ns/j2ee" version="1.4"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com /xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd">
    <display-name>HelloWorld</display-name>
    <description>Application description</description>
    <module>
    <web>
    <web-uri>web-ejb3.war</web-uri>
    <context-root>HelloWorld</context-root>
    </web>
    </module>
    </application>
    [root]\build.xml:
    <project name="HelloWorld" default="all" basedir=".">
    <!-- Name of project and version -->
    <property name="proj.name" value="HelloWorld"/>
    <property name="proj.version" value="1.0"/>
    <!-- Global properties for thid build -->
    <property name="src.dir" value="${basedir}/src"/>
    <property name="build.dir" value="${basedir}/bin"/>
    <property name="lib.dir" value="${basedir}/lib"/>
    <property name="build.classes.dir" value="${build.dir}/classes"/>
    <property name="build.jar.dir" value="${build.dir}/jar"/>
    <property name="src.etc.dir" value="${basedir}/etc"/>
    <property name="meta-inf.dir" value="${src.etc.dir}/META-INF"/>
    <!-- The build classpath -->
    <path id="build.classpath">
    <fileset dir="${lib.dir}">
    <include name="**/*.jar"/>
    <include name="**/*.zip"/>
    </fileset>
    </path>
    <!-- Useful shortcuts -->
    <patternset id="meta.files">
    <include name="**/*.xml" />
    <include name="**/*.properties"/>
    </patternset>
    <target name="prepare">
    <mkdir dir="${build.dir}"/>
    <mkdir dir="${build.classes.dir}"/>
    <mkdir dir="${build.jar.dir}"/>
    </target>
    <target name="compile" depends="prepare">
    <javac destdir="${build.classes.dir}"
    classpathref="build.classpath"
    debug="on">
    <src path="${src.dir}"/>
    </javac>
    </target>
    <target name="package-web" depends="compile">
    <war warfile="${build.dir}/jar/web-ejb3.war"
    webxml="${meta-inf.dir}/web.xml">
    <classes dir="${build.dir}/classes">
    <include name="**/*Servlet.class"/>
    </classes>
    </war>
    </target>
    <!-- Creates an ear file containing the web client war. -->
    <target name="assemble-app">
    <ear destfile="${build.jar.dir}/HelloWorld.ear" appxml="${meta-inf.dir}/application.xml">
    <fileset dir="${build.dir}/jar"
    includes="*.war"/>
    </ear>
    </target>
    <target name="clean">
    <delete dir="${build.dir}" />
    </target>
    <target name="all">
    <antcall target="clean" />
    <antcall target="package-web" />
    <antcall target="assemble-app" />
    </target>
    </project>
    Any help would be apreciated.
    Thanks in advance,
    Hugo Oliveira
    [email protected]

    Hello Ken.
    I gess dependency injection is unnavailable in servlets as of this moment. I conducted another test using a session bean that injects and tests the DataSource and a servlet calling the session bean via a refference obtained from InitialContext. It worked OK.
    Here's the code:
    [root]/src/hello/MessageHandler.java:
    package hello;
    public interface MessageHandler {
         public boolean testInjection();
    [root]/src/hello/MessageHandlerBean.java:
    package hello;
    import javax.ejb.Stateless;
    import javax.persistence.*;
    import java.util.List;
    import javax.annotation.*;
    @Stateless
    public class MessageHandlerBean implements MessageHandler {
         @Resource (mappedName="java:/DefaultDS")
         private javax.sql.DataSource ds;     
         public boolean testInjection() {
              try {
                   java.sql.Connection conn = ds.getConnection();
                   conn.close();
                   return true;
              } catch(Exception e) {
                   e.printStackTrace();
              return false;
    [root]/src/hello/MessageServlet.java:
    package hello;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.util.List;
    import java.util.ListIterator;
    import javax.naming.InitialContext;
    import javax.annotation.*;
    public class MessageServlet extends HttpServlet {
         public void init () throws ServletException {
         public void service(HttpServletRequest request, HttpServletResponse response)
                   throws IOException, ServletException {
              boolean injectedLookingGood = false;
              try {
                   InitialContext ic = new InitialContext();
                   MessageHandler mh = (MessageHandler)ic.lookup("HelloWorld/MessageHandlerBean/local");
                   injectedLookingGood = mh.testInjection();
              } catch(Exception e) {
                   e.printStackTrace();
              response.setContentType("text/html");
              ServletOutputStream out = response.getOutputStream();
              out.println("<html>");
              out.println("<head><title>Hello World</title></head>");
              out.println("<body>");
              out.println("<h1>Hello World</h1>");
              out.println("<form action=\"HelloWorld\" method=\"get\">");
              out.print("Injected DataSource is looking ");
              if(injectedLookingGood) {
                   out.println("good <br>");
              else {
                   out.println("bad <br>");
              out.println("<input type=\"submit\" value=\"Test Some More\">");
              out.println("</form>");
              out.println("</body>");
              out.println("</html>");
    [root]/etc/META-INF/application.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <application xmlns="http://java.sun.com/xml/ns/j2ee" version="1.4"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com /xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd">
    <display-name>HelloWorld</display-name>
    <description>Application description</description>
    <module>
    <ejb>HelloWorld.ejb3</ejb>
    </module>
    <module>
    <web>
    <web-uri>web-ejb3.war</web-uri>
    <context-root>HelloWorld</context-root>
    </web>
    </module>
    </application>
    [root]/etc/META-INF/web.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
    "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
    <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    <display-name>HelloWorldWAR</display-name>
    <servlet>
    <display-name>HelloWorld</display-name>
    <servlet-name>HelloWorldServlet</servlet-name>
    <servlet-class>hello.MessageServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>HelloWorldServlet</servlet-name>
    <url-pattern>/servlet/HelloWorld</url-pattern>
    </servlet-mapping>
    </web-app>
    [root]/build.xml:
    <project name="HelloWorld" default="all" basedir=".">
    <!-- Name of project and version -->
    <property name="proj.name" value="HelloWorld"/>
    <property name="proj.version" value="1.0"/>
    <!-- Global properties for thid build -->
    <property name="src.dir" value="${basedir}/src"/>
    <property name="build.dir" value="${basedir}/bin"/>
    <property name="lib.dir" value="${basedir}/lib"/>
    <property name="build.classes.dir" value="${build.dir}/classes"/>
    <property name="build.jar.dir" value="${build.dir}/jar"/>
    <property name="src.etc.dir" value="${basedir}/etc"/>
    <property name="meta-inf.dir" value="${src.etc.dir}/META-INF"/>
    <!-- The build classpath -->
    <path id="build.classpath">
    <fileset dir="${lib.dir}">
    <include name="**/*.jar"/>
    <include name="**/*.zip"/>
    </fileset>
    </path>
    <!-- Useful shortcuts -->
    <patternset id="meta.files">
    <include name="**/*.xml" />
    <include name="**/*.properties"/>
    </patternset>
    <target name="prepare">
    <mkdir dir="${build.dir}"/>
    <mkdir dir="${build.classes.dir}"/>
    <mkdir dir="${build.jar.dir}"/>
    </target>
    <target name="compile" depends="prepare">
    <javac destdir="${build.classes.dir}"
    classpathref="build.classpath"
    debug="on">
    <src path="${src.dir}"/>
    </javac>
    </target>
    <target name="package-ejb" depends="compile">
    <jar jarfile="${build.jar.dir}/HelloWorld.ejb3">
    <fileset dir="${build.classes.dir}">
    <include name="**/*.class"/>
    </fileset>
    <!--
         <metainf dir="${meta-inf.dir}">
    <include name="persistence.xml"/>
    </metainf>
    -->
    </jar>
    </target>
    <target name="package-web" depends="compile">
    <war warfile="${build.dir}/jar/web-ejb3.war"
    webxml="${meta-inf.dir}/web.xml">
    <!--
    <fileset dir="web">
    <include name="**/*"/>
    </fileset>
    -->
    <!--
    <webinf dir="dd/web">
    <include name="jboss-web.xml"/>
    </webinf>
    -->
    <classes dir="${build.dir}/classes">
    <include name="**/*Servlet.class"/>
    </classes>
    </war>
    </target>
    <!-- Creates an ear file containing the ejb jars and the web client war. -->
    <target name="assemble-app">
    <ear destfile="${build.jar.dir}/HelloWorld.ear" appxml="${meta-inf.dir}/application.xml">
    <fileset dir="${build.dir}/jar"
    includes="*.ejb3,*.war"/>
    </ear>
    <!-- <delete file="${build.dir}/jar/web-ejb3.war"/>
    <delete dir="${build.dir}/classes"/> -->
    </target>
    <target name="clean">
    <delete dir="${build.dir}" />
    </target>
    <target name="all">
    <antcall target="clean" />
    <antcall target="package-ejb" />
    <antcall target="package-web" />
    <antcall target="assemble-app" />
    </target>
    </project>
    Thanks,
    Hugo Oliveira
    [email protected]

  • Problem with index.jsp and JSF

    hi all
    I have an index page "index.jsp" in the root directory of deployed project and in that page there is just a <jsp:forward> tag:
    <jsp:forward page="pages/mainPage.jsf" />I am using facelets and I have a template.xhtml
    when I run the browser nothing will be desplayed. by looking at Tomcat console, it seems that it renders the template.xml. if I place the path of the page directly in the address bar of browser, everything is OK
    http://localhost:8080/myproject/pages/mainPage.jsf
    but if I put following, it doesnt work.
    http://localhost:8080/myproject/
    I set the welcome-page to index.jsp in web.xml, and my pages are located in a directory namely "pages"
    any help will be appreciated.
    regards
    Mohammad

    I'm not sure what the problem is exactly. This topic might help though:
    http://forum.java.sun.com/thread.jspa?threadID=696586
    Be sure to read right to the bottom. You may be able to try a couple other things.
    Hope this helps,
    CowKing

  • Compilation problem in a JSP page

    Hi all,
    I'm trying to write a jsp page and some java stuff in it.
    It goes something like this -
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <%@ page contentType="text/html;charset=windows-1255"%>
    <html>
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=windows-1255"/>
        <title>Michael</title>
      </head>
      <body>
    <%
              String strError="";
    %>
    </body>Now the problem is that I get compilation problem about the use in java -
    "String cannot be resolved to a type"
    I know for sure that in other computers it's work, the question is what I'm missing?
    I have Java VM installed and I've downloaded and installed the latest JDK, what else?
    thanks,
    Michael.

    Michael4488 wrote:
    BalusC wrote:
    Then you should be using JSTL/EL.I don't familiar with this technology, any way - Its work on one computer so in my understanding it should work on the other as well.It is not related to the actual problem. It was just a comment on your code. Using scriptlets is considered as bad practice.
    I understand that of course, but I don't use any configuration file or set any special parameters in my computer.
    What exactly does the compiler need in order to recognize the Java code in the JSP page? If i manually add the JAVA_HOME environment variable it will work?
    where should I refer it to? "..\Java\jre1.6.0_07\lib" will do?It must point to the root installation directory of the JDK (thus not the JRE!).

  • Problem in creating Jsp Page.

    i am working on bulletin board Project.
    now my problem is that how to create Dynamic Page.
    Suppose :-
    i have created a Jsp page in that page there are 4 Categories like ( Java , dot net , PHP , XML ).
    ok
    Now when u click on it suppose java a new jsp page will open if u logdin through yout login ID the u can able to post any thing related to java lie Quation or Ans etc.
    ok
    now u have posted a quation now the problem is that wen u have posted a quation in java section it will stored in database but how can i display that quation in new page & if some one reply to that Quation the how can i display that Ans just under that quation.
    At that moment i have to create a jsp page Dynamically. i am right so how can i do that PL help me i have to submit my project withen 3 to 5 days in my collage PL.
    PL Hellp me & tell me how to do that.
    Thanks
    HARSH

    It is generally a bad idea to start threads in JSPs and Servlets. However, there is a need for them ... sometimes... Stress the rarety of sometimes. If you want to cancel the TimeTask, then chances are you don't want the Timer running from your JSP.
    To answer your question, how is the Timer/TimerTask objects you are working with stored? To make changes, they would need to be stored in some scope where they can be accessed later. That means session if you want different users to have dirrerent tasks. application scope if all users should control the same task (be careful with this, you may have problems with synchronization issues).
    I would think there is probably a better solution to your problem. Maybe if you explain in more detail, we can come up with a better one.

  • Problem in loading jsp page

    Hi ,
    I'm facing a problem in displaying a JSP page . I'm displaying records from the database on the page . I want to display only 20 records at a time . I have given the navigation facility for previous,first ,last ,next etc.
    I'm getting all the records at once and displaying them at once . But , I show only 20 records at a time ,hiding the remaining records .
    This works fine for less no . of records but for more records ,say 2000-3000 records , it gets quite slow as expected .
    I don't want to fire the query again .
    Is there any other way possible using this technique .
    It's very urgent . So kindly help .
    Thanks.

    Just get a scrollable ResultSet with the row amount for 1 page, e.g.
          * Returns a result set for the given query, that is read only and scrollable
         * (cursor can move forward and backward). The default fetch size is used and
         * can be changed anytime by calling resultSet.setFetchSize(newFetchSize).
         * <p>
         * Note: be sure that the used JDBC driver supports scrollable result sets via
         * <code>DatabaseMetaData.supportsResultSetType(ResultSet.TYPE_SCROLL_SENSITIVE)</code>
          * @param select SQL select query.
         * @param fetchSize Number of rows to prefetch.
          * @return Scrollable, read-only result set.
        private ResultSet getScrollableResultSet(String select, int fetchSize) {
            ResultSet result = null;
            if (select != null) {
                try {
    //TYPE_SCROLL_SENSITIVE can throw SQLException "Unsupported syntax for refreshRow()" with the
    //current ORACLE driver (8.1.7.0.0).
    //                Statement stmt = createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
                    Statement stmt = createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
                    int maxRows = stmt.getMaxRows();
                    if (fetchSize < 0 || fetchSize > maxRows) {
                        fetchSize = 0; //ignore fetch size
                    stmt.setFetchSize(fetchSize);
                    long t = System.currentTimeMillis();
                    result = stmt.executeQuery(select);
                    logger.debug(select + (" ("+(System.currentTimeMillis() - t)+")"));
                    if (result == null) {
                        stmt.close();
                } catch (SQLException sqle) {
                    logger.error("Error getting scrollable ResultSet for '"+select+"'.", sqle);
                    throw new BavException(sqle);
            return result;
        }//getScrollableResultSet()and fetch the next/previous page records via the resultSets next()/previous() methods. But beware that the SQL statement doesn't use an ORDER BY or GROUP BY that needs to fetch all rows anyway.

  • Ergent problem with the jsp file access in tomcat. HELP...

    I use tomcat as my server, I have one JSP file located in :
    webapps\abc\war\WEB-INF\jsp\index.jsp
    You see my project name is abc, I want to access the index.jsp file, I define another jsp file in the path: webapps\abc callled outside.jsp. I want to use outside.jsp to invoke the index.jsp.
    Inside outside.jsp it is :
    <html>
    <head>
    <title>index</title>
    </head>
    <body>
    <%@ include file="war/WEB-INF/jsp/index.jsp" %/>
    </body>
    </html>
    When I open the browser, and access, http://localhost:8080/abc/outside.jsp , the content of index.jsp was shown as expect. But, all the link pages of the index.jsp can not shown (PS: the link pages is located in the same path as index.jsp, they are all jsp files). I guess the problem may be that the <%@ include file="war/WEB-INF/jsp/index.jsp" %/> inside outside.jsp include the index.jsp as a static file. Is there any method to make all the link pages of index.jsp can be shown when call from outside.jsp???HELP
    Message was edited by:
    Mellon
    Message was edited by:
    Mellon

    I don't know why your links can't be shown, but I can tell you that your suspect:
    I guess the problem may be that the <%@ include file="war/WEB-INF/jsp/index.jsp" %/> inside outside.jsp include the index.jsp as a static file.is wrong, because included jsp is dynamic, not static.

  • Problem in compiling jsp file

    Hi,
    i am using tomcat 4.12 and jdk 1.4.
    My login page contains 3 frames. after succesful login into ur application, 7 frames are getting called.
    i have called a jsp page for each frame.
    sometimes while accessing my application, i am getting jasper exception like cannot resolve symbol....
    for example
    D:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\sample\web\helpdesklogin_jsp.java:404: cannot resolve symbol
    symbol : method --ite  (java.lang.String)
    location: class javax.servlet.jsp.JspWriter
    out.write("<tr bgcolor=\"ffffff\">\r\n ");
    i do not understand the what is the problem here....
    likewise i am getting jasper exception. but it is not frequently occured in the frame.
    is there any relation with autoflush page directive attribute...?
    if it then should i increase default buffer size ?
    Reply please
    Thanks

    Your helpdesklogin.jsp file has a compilation error. It's hard to tell, but it looks like you mis-typed out.write() somewhere.
    - Saish

Maybe you are looking for