JSP page import directive

I'm running JSPs and servlets under Netscape (Tomcat) web server and am getting errors with my jsp file's first line:
[%@page import="java.util.*, myclass" %]
Netscape server throws an error saying that it can't import myclass. I've put the myclass.class file in various locations in the server but it still can't find it. Does anyone know a foolproof way to make the server find such a class when it's compiling jsp's?
Thanks,
David

I think you have to specify package name of your class & not your calss name.

Similar Messages

  • Trying to page import directive in a JSP  access a class in default package

    I am trying to import a class the is in my default package directory for Tomcat 4.1.18 (context-root\web-inf\classes\*.java). I am getting the following error
    This is error using Tomcat 4.1.18
    org.apache.jasper.JasperException:Unable to compile class for JSP
    C:\Program Files\Tomcat4.1\work\Standalone\localhost\csc297\HTML\SearchByName_jsp.java:9: '.' expected
    import Product;
    C:\Program Files\Tomcat4.1\work\Standalone\localhost\csc297\HTML\SearchByName_jsp.java:10: '.' expected
    import Category;
    This is error using Tomcat 4.0.6
    org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.
    C:\forte4j\tomcat401\work\localhost\C_3A_5Cforte4j_5Ctomcat401_5Cwebapps_5Ccsc297\HTML\SearchByName$jsp.java:5: Class Product not found in import.
    import Product;
    ^
    C:\forte4j\tomcat401\work\localhost\C_3A_5Cforte4j_5Ctomcat401_5Cwebapps_5Ccsc297\HTML\SearchByName$jsp.java:6: Class Category not found in import.
    import Category;
    Here is snippet of code from my JSP:
    <%@ page import= "java.util.*"%>
    <%@ page import= "java.text.DecimalFormat"%>
    <%@ page import="Product"%>
    <%@ page import="Category"%>
    Remember these classes are in my default package of my context-root
    Any ideas would greatly appreciated

    Weird error. Never seen this one before.
    Try packaging your classes eg:package myClasses;and import them:<%@page import="myClasses.*"%>Should fix the problem.
    Anthony

  • JSP page import problems

    Hi,
    i've got a problem with importing java classes into my jsp file. i use the following method:
    <%@ page import="Person" %>
    Person is originally a selfwritten class which lies in the subdirectory WEB-INF/classes of my webapps directory of my tomcat server. when i use the above method i get the following error output:
    org.apache.jasper.JasperException: Unable to compile class for JSP An error occurred at line: 125 in the jsp file: /ShowPersonsView.jsp Generated servlet error:
    [javac] Compiling 1 source file 3 3 /usr/local/tomcat/work/Standalone/localhost/address/ShowPersonsView_jsp.java:7: '.' expected
    import Person;
    ^
    /usr/local/tomcat/work/Standalone/localhost/address/ShowPersonsView_jsp.java:231: cannot resolve symbol
    symbol : class Person
    location: class org.apache.jsp.ShowPersonsView_jsp
    Person tempperson;
    ^ An error occurred at line: 125 in the jsp file: /ShowPersonsView.jsp Generated servlet error:
    /usr/local/tomcat/work/Standalone/localhost/address/ShowPersonsView_jsp.java:238: cannot resolve symbol
    symbol : class Person
    location: class org.apache.jsp.ShowPersonsView_jsp
    tempperson = (Person)it.next();
    ^
    3 errors at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:120)
    at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:293)
    at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:313)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:324)
    at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:474)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:184)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:289)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:432)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:356)
    at ShowPersonsPrepare.doGet(ShowPersonsPrepare.java:51)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2396)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
    at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:405)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:380)
    at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:508)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:533)
    at java.lang.Thread.run(Thread.java:536)
    Thus, the Person class can not be found but i dunno why. Where do I have to make an entry? I already tried to set a classpath to this file, but it doesn't work. Has anyone an idea?
    Thanx

    Put the class in a package and call it accordingly. Example:
    WEB-INF
       |
        --- classes
               |
                --- example
                       |
                        --- Person.java
    //then in Person add:
    package example;
    //and in jsp
    <%@ page import="example.Person" %>

  • Getting error message "Only a type can be imported-" when trying to execute jsp page

    I get the error: "Only a type can be imported. com.adobe.cq.TestServiceImpl resolves to a package in adobe day cq5
    I have created one bundle and installed in felix console. The status of the bundle is also Active. And also it is available in both service and component console.
    Here is my TestServiceImpl class in com.adobe.cq bundle
    package com.adobe.cq;
    import org.apache.felix.scr.annotations.Component;
    import org.apache.felix.scr.annotations.Service;
    import org.osgi.framework.BundleContext;
    import org.osgi.service.component.ComponentContext;
    import javax.jcr.RepositoryException;
    import org.apache.felix.scr.annotations.Property;
    import org.apache.felix.scr.annotations.Properties;
    //src.component
    //declares the class component. This will provide a wrapped ManagedService component in the OSGI container.
    //src.service interface="SampleService"
    //declares the service we are offering. Actually, the interface attribute is superflous, as by default, all implemented Interfaces are used.
    @scr.component
    @scr.service interface="testService"
    @Component(immediate = true, metatype = true)
    @Service
    @Properties( {
    @Property(name = "service.description", value = "abcd"),
    @Property(name = "label", value = "myLabel") })
    public class TestServiceImpl implements TestService {
    public String sayHello() {
         return "Hello World!";
    Here is my jsp code
    <%@include file="/libs/foundation/global.jsp"%><%
    %><%@include file="/apps/mine/includes/functions.jsp"%><%
    %><%@ page import="com.adobe.cq.TestServiceImpl,
    org.apache.sling.api.SlingHttpServletRequest,
                    java.util.List"%><%
    %><%
    SlingHttpServletRequest r = (SlingHttpServletRequest)request;   
                    TestServiceImpl testService = sling.getService(TestServiceImpl.class);
                    out.println("testService:::"+testService);
    %>
    <div id="te-nav" style="display:block !important;">
    </div>
    Is it because of am using annotation in TestServiceImpl class?
    Could you please tell me how to fix it?
    Regards,
    Anderson

    Hi Pawan,
    Thanks for your information. It was problem with my pom.xml It started to work after changing my POM.xml
    I am not able to get sling service for TestServiceImpl. But I am only able to create TestService which is my interface. I need to get reference for TestServiceImpl class not for TestService interface. Please help me to make it.
    i have created TestServiceImpl and TestService class for testing whether my bubdle is crating all the folder structure or not.
    But my requirement is like assume class A has some methods like getMenuLink, setMenuLink.. And In class B i am calling some methods in class A and doing some manipulation in createLink method.
    Here class B does not have any interface. Not implementing  any interface. But I need to get class B refererence via sling.getService.
    I know that if we are using maven SCR plugin..we need to have @component, @service. And All java classes are not services. Will it work if I add activate, deactivate method in class B?
    Could you please tell me how to proceed next?
    Thanks,
    Anderson

  • Render a JSP page into HTML in a String

    I am using a mail template system that gets templates as JSP pages placed in /WEB-INF/mailtemplates/
    I want to internally parse JSPs as if they were real JSPs in my tomcat but:
    - Get get them using getResourceAsStream (or any other way)
    - make JSP engine translate JSP into HTML into a String object.
    - Send a mail with this HTML. (this part is already finished)
    What I need is a method with the following proposed signature:
    public String getMailTemplate(java.io.InputStream jspPageStream, javax.servlet.HttpServletRequest request) {}
    The method must get the JSP from the stream, render it into the HTML and return it as a String.
    Of course, it must render the JSP as a real JSP, using the apserver JSP engine. It must so replace any tags and EL objects:
    ${session.user.name} -> The name of the user
    <c:forEach, ...
    etc. etc. etc.
    �Any ideas / directions on how to achieve this?
    thanks,
    Ignacio

    Ok, just tried it out myself, and I'm getting the same result you are.
    Nothing makes it out to the RedirectingServletResponse.
    It appears to be buffering it somewhere in the included page.
    If you put a command to flush the buffer on the jsp page being included: <% out.flush; %> then it works.
    So why doesn't it work normally? Why doesn't the call to requestDispatcher.include (or forward) flush/commit its response?
    I will admit to being stuck on this one. I'm figuring its something in the internal workings of Tomcat/JSP to do with when a page is flushed or not, but I can't thing of anything right now.
    Here is the test I put together to try this out (along with a few corrections to my previous code). I will admit to being stumped :-)
    The response wrapper:
    package web;
    import java.io.IOException;
    import java.io.OutputStream;
    import java.io.PrintWriter;
    import javax.servlet.ServletOutputStream;
    import javax.servlet.ServletResponse;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpServletResponseWrapper;
    public class RedirectingServletResponse extends HttpServletResponseWrapper {
        RedirectServletStream out;
         * @param arg0
        public RedirectingServletResponse(HttpServletResponse response, OutputStream out) {
            super(response);
            this.out = new RedirectServletStream(out);
        /* (non-Javadoc)
         * @see javax.servlet.ServletResponse#flushBuffer()
        public void flushBuffer() throws IOException {
             out.flush();       
        /* (non-Javadoc)
         * @see javax.servlet.ServletResponse#getOutputStream()
        public ServletOutputStream getOutputStream() throws IOException {
            return out;
        /* (non-Javadoc)
         * @see javax.servlet.ServletResponse#getWriter()
        public PrintWriter getWriter() throws IOException {
            return new PrintWriter(out);
        /* (non-Javadoc)
          * @see javax.servlet.ServletResponseWrapper#getResponse()
         public ServletResponse getResponse() {
              return super.getResponse();
         /* (non-Javadoc)
          * @see javax.servlet.ServletResponseWrapper#setResponse(javax.servlet.ServletResponse)
         public void setResponse(ServletResponse arg0) {
              super.setResponse(arg0);
         private static class RedirectServletStream extends ServletOutputStream {
            OutputStream out;
            RedirectServletStream(OutputStream out) {
                this.out = out;
            public void write(int param) throws java.io.IOException {
                out.write(param);
    A JSP using this class: requestWrapperTest.jsp
    <%@ page import="java.io.*" %>
    <%@ page import="web.RedirectingServletResponse" %>
    <%@ page contentType="text/html;charset=UTF8" %>
    <%!
    public String getEmailText(HttpServletRequest request, HttpServletResponse response, String emailURL) {
         try{
           // create an output stream - to file, to memory...
           ByteArrayOutputStream out = new ByteArrayOutputStream();
           // create the "dummy" response object
           RedirectingServletResponse dummyResponse;
           dummyResponse = new RedirectingServletResponse(response, out);
           // get a request dispatcher for the email template to load 
           RequestDispatcher rd = request.getRequestDispatcher(emailURL);
           // execute that JSP
           rd.include(request, dummyResponse);
           // at this point the ByteArrayOutputStream has had the response written into it.
           dummyResponse.flushBuffer();
           byte[] result = out.toByteArray();
           System.out.println("result = " + result.length);
           // now you can do with it what you will.
           String emailText = new String(result);
           return emailText;
         catch (Exception e){
              e.printStackTrace(System.out);
              return "DANGER WILL ROBINSON!";
    %>
    <html>
    <body>
    <h2> Server Info Virtual!!</h2>
    Server info = <%= application.getServerInfo() %> <br>
    Servlet engine version = <%=  application.getMajorVersion() %>.<%= application.getMinorVersion() %><br>
    Java version = <%= System.getProperty("java.vm.version") %><br>
    <hr>
    <%
      String result = getEmailText(request, response, "/testLoad.jsp");
      System.out.println(result);
    %>
    <%= result %>
    </body>
    </html>------------------------------------------------------------------
    And the template page being included: testLoad.jsp
    This is the page loaded for testing
    <%
       System.out.println("in the inner jsp");
       // uncomment the following line to see this example work
       //out.flush();
    %>

  • How to use Session scope in jsp page

    Hello, I have login form, where user provides username and password. Then click on submit, it will forward to validation.jsp. Where it will check in database make sure username and password exit. Now i can also retrive accountid of perticular user. I want to put that username and accountid in session scope. so all other pages can use that username and accountid. How can i do that. I'm new at this, so please provide me example too. Here is my code for login.jsp and validation.jsp..
    Validation.jsp
    <%@ page import="java.util.*" %>
    <%@ page import="java.sql.*" %>
    //String name = request.getParameter( "username" );//
    //session.setAttribute( "accountID",accountID );//
    <%
    String connURL = "jdbc:oracle:thin:@orca.csc.ncsu.edu:1521:ORCL";
         Connection conn = null;
         Statement stmt = null;
         ResultSet rs = null;
    Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
    conn = DriverManager.getConnection(connURL, "vapatel","pjdas");
    stmt = conn.createStatement();
    String user=request.getParameter("userName");
    String password=request.getParameter("password");
    boolean entrance=false;
    stmt.excuteQuery("SELECT AccountID From Password WHERE USERNAME='"+user+"'");
    rs = stmt.executeQuery("SELECT * FROM Password WHERE USERNAME='"+user+"' AND PASSWORD='"+password+"'");
    while(rs.next()){
    String dbUser = rs.getString("USERNAME");
    String dbPassword= rs.getString("PASSWORD");
    if ((user.equals(dbUser)) && (password.equals(dbPassword))){
    entrance=true;
    if (entrance==true){%>
    <jsp:forward page="form.jsp"/>
    <%}
    else{%>
    <jsp:forward page="login.jsp"/>
    <%}
    %>

    hi,
    to put something into session scope in a jsp page use:
    session.setAttribute("counter", Integer.toString(5));to retrieve is from a jsp page use:
    String counterAttribute = (String)session.getAttribute("counter");

  • Include jsf file in a jsp page

    Hi Everyone,
    I have a plain jsp page with no JSF Components, but it has a jsp:include tag which is another jsp file which contains jsf components.
    When i try to run the plain jsp file ... i get the following error...
    java.lang.IllegalStateException: Cannot forward after response has been committed
         at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:324)
         at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:312)
         at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
         at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:147)
         at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
         at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
         at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
         at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:703)
         at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:589)
         at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:499)
         at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:966)
         at org.apache.jsp.DynamicWebpart_jsp._jspService(DynamicWebpart_jsp.java:278)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:298)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
         at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:703)
         at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:589)
         at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:499)
         at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:966)
         at org.apache.jsp.Webpart_jsp._jspService(Webpart_jsp.java:302)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:298)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
         at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:703)
         at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:589)
         at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:499)
         at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:966)
         .......... so.....on........
    I saw the source code for the plain jsp file and the error is because of including the jsp file with jsf components.
    The contents of both the jsp file is given below
    Plain jsp file
    DWStaticJSP.jsp
    <%@ page import="java.util.*" %>
    <%@ page import="com.mirus.bi.jsp.*" %>
    <%@ page import="com.mirus.bi.util.Log" %>
    <% Log.logDbg("*******before calling the faces file from DWStatic :"+rSetting.getStaticJSPFileName()); %>
    // name of the file name : /faces/report_palm.jsp
    <jsp:include page="<%=rSetting.getStaticJSPFileName()%>" flush="false" >     
                   <jsp:param name="DMode" value="DBoard" />
    </jsp:include>
    Jsp file with JSF component
    it is stored in faces folder
    /faces/report_palm.jsp
    <%@ page contentType="text/html" %>
    <%@ page import="com.mirus.bi.util.Log" %>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
    <%@ taglib uri="http://mirus.com/jsftaglib" prefix="my" %>
    <f:view>
              <h:outputText value="Store Name:" />
              <h:outputText value="#{palmReportUIHandler.currentStoreDisplay}" />
              <h:outputText value="Year:" />
              <h:outputText value="#{palmReportUIHandler.currentYear}" />
              <h:outputText value="Month:" />
              <h:outputText value="#{palmReportUIHandler.currentMonth}" />
    </f:view>
    The Configuration in the web.xml for faces Servlet is given below
    <servlet>
    <servlet-name>FacesServlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <!-- Faces Servlet Mapping -->
    <servlet-mapping>
    <servlet-name>FacesServlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>
    Does anybody know the solution to this problem
    Any kind of help will be highly appreciated.
    Pinkesh

    Hi Adam Winer,
    I want to try your solution.
    just wanted some more clarification .....
    So, let's say you have:
    DWStaticJSP.jsp: plain JSP
    report_palm.jsp: JSF JSP included by DWStaticJSP.jsp
    What you should do is use an URL of:
    /faces/DWStatic.jsp
    to access the outer plain JSP (yes, even though it's not really a faces page), and then have
    /faces/DWStatic.jsp include just plain /report_palm.jsp.
    In essence, the critical thing is that the FacesServlet wraps the entire request - FacesServlet cannot run
    for just a piece of the request.My question is where should i store the DWStatic.jsp file ... As u said i should acces it using /faces/DWStatic.jsp do i need to save it in the faces folder or just in the web app root.
    I cant save the DWStatic.jsp in the faces folder as this file is used for lot of different purpose in my company application.
    So can u give me a solution where in i can keep the DWStatic.jsp in the web-root folder and still try your solution
    Also is this the right setting for facesServlet in the web.xml.
    <servlet>
    <servlet-name>FacesServlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <!-- Faces Servlet Mapping -->
    <servlet-mapping>
    <servlet-name>FacesServlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>
    Whatever follows below this line is the describtion of the web appp structure which i have in my company.
    We have an application where in all the jsp files are stored in the web-app root folder.....
    I will be using alphabets like a.jsp ... b.jsp .... to keep the explanation small...
    I have an a.jsp file which includes a b.jsp file which in turn includes a c.jsp......
    Now we have started using JSF.....
    Now as a developer .... i want the c.jsp to include a d.jsp file which contains JSF components...
    The thing is i cant change the location of a.jsp, b.jsp and c.jsp......
    Can u tell me how i should call " a.jsp" ... imean the url so that the "d.jsp" file gets processed properly.
    Also where should i save all the jsp files and what config is requiered in the web.xml for your solution
    I thank you for your help
    Pinkesh

  • How to use java class in jsp page of JSPProvider?

    Hello everybody.
    I created simple JSPProvider channel with portal amconsole and named it "jspprov1". Then I created "jspprov"1 directory under "/ets/opt/SUNWps/desktop/sampleportal". I put "index.jsp" in it. And it worked until I add this line into "index.jsp": <% @page import="jspprov1package.aclass1" %>. Then I created directory "jspprov1package" under "/ets/opt/SUNWps/desktop/classes" and put "aclass1.class" into it and into "/ets/opt/SUNWps/desktop/classes" itself. I created "aclass1.class" on the other machine (with no installed portal) in j2sdk1.4.1_02: "javac aclass1.java". The text of this class is simple:
    "package jspprov1package;
    public class aclass1{
    public int int_field = 10;
    But the page still don't work. It writes on the portal desktop "ERROR: Content is not available".
    Does anybody know why this happened?

    Sorry, there were mistakes in jsp page and java files.
    I maked the channel "show exceptions" and found them out.

  • ER: organize imports in an "import" attribute of a JSP page directive

    Hi,
    it would be useful to see packages/classes hierarchy when changing the "import" attribute of <%@ page %> directive. It might be as well to have all possibilities of imports processing as in .java classes (autoadding, remove unused import, etc.)
    Thanks in advance.

    Hello Scott,
              First, you have to define this page directive in your static page or JSP
              page :
              <%@ page contentType="text/html; charset=UTF8" %>
              Check your your weblogic.properties file for the following settings:
              weblogic.httpd.inputCharset specifies encoding used when changing into the
              internal code of Java from the parameter of the browser's request. If you
              use Shift_JIS in HTML or JSP, please set
              weblogic.httpd.inputCharset./*=Shift_JIS.
              weblogic.codeset specifies encoding used when jDriver stores data in an
              Oracle database and it changes into the character code of a database from
              the internal code of Java. If you use ja16sjis in Oracle database, please
              set the same encoding as NLS_LANG to weblogic.codeset.
              Hope this helps
              Ludovic.
              Developer Relations Engineer
              BEA Support
              "Scott Mark" <[email protected]> a écrit dans le message news:
              3cd67e5d$[email protected]..
              > Did you ever get around this? Is there an issue with UTF-8 encoding?
              >
              > We are going to have to deliver a site in Japanese soon, and are
              researching how well WLS handles double-byte chars...
              

  • Import java-classes in JSP-page

    Hi,
    I'm starting with JSP and with trying one of the first examples in the book "beginning J2EE 1.4" from wrox, i got following problem.
    i'm trying to import a java-class in the package CH03 with
    <%@ page import="Ch03.FaqCategories" %>but he didn't find the package Ch03.
    I try already many things and i have no idea of the cause of the problem. So it's difficult to give information that leads to the solution.
    Maybe helpfull is the direcory-structure:
    jsp-page: /Ch03/welcome.jsp
    java-classe: /Ch03/WEB-INF/classes/Ch03/FaqCategories.class
    If you need source-codes or other information, just ask.
    Thanks,
    Dennis

    Thank you,
    Your help was one step into the good direction and that problem is solved.
    The application work now with studio one, but if i try it to work it with a stand-alone tomcat server it doesn't work anymore. I go first try to solve this problem by my self or at least try to describe the problem more exactly, before i ask for new help.
    but if you have any idea, that's always welcome...
    with regards,
    Dennis

  • Multiple import directives in jsp

    I have a JSP and in my page directive I have an import as follows: import="java.util.*" which works fine
    However if I add another one eg import="java.text.*" I get an error message because it only seems to pick up one import. Anydbody know what is going wrong?
    Thanks!!

    Not exactly sure whats wrong here because I can't see all your code, but you can definetely import more than one class like this:
    <%@ page import="java.util.*, java.text.*" %>

  • Where to add directive on a JSP page?

    Do we have t o add a directive like an import packages directive, on the top of the JSP page ONLY. Or can we place it anywhere in the file ...may be just above when you have the java code.
    Example:
    Should I place:
    <%@ page import = "java.util.*, java.lang.*,java.text.* " %>right above my <html> tag or can I place it inside my <body> wher eI have some code Example:
    String i="123";
    int k= Integer.parseint(i);Will that change the way the JSP works?
    I know that compiling is done top to bottom, but how does it effect the performance?
    Are all directives loaded initially, when the program is run?
    Thanks,
    Kishore

    It's good to add it on top of the file. But for your code to work, you are required to add directive at least before you write any java code in your jsp file.

  • Importing classes into JSP page

    Hi There,
    I am new to this and here is my problem.
    I am doing a shopping cart tutorial and trying to get a JSP page to import two classes :
    <%@ page language="java" contentType="text/html"
    import="ShoppingBasket,Product"
    errorPage="errorpage.jsp" %>
    I get :
    C:\jakarta-tomcat-4.1.30\work\Standalone\localhost\_\shop_0002dbasket_jsp.java:7: '.' expected
    import ShoppingBasket;
    ^
    C:\jakarta-tomcat-4.1.30\work\Standalone\localhost\_\shop_0002dbasket_jsp.java:8: '.' expected
    import Product;
    ^
    C:\jakarta-tomcat-4.1.30\work\Standalone\localhost\_\shop_0002dbasket_jsp.java:50: cannot resolve symbol
    symbol : class ShoppingBasket
    location: class org.apache.jsp.shop_0002dbasket_jsp
    ShoppingBasket basket = null;
    The classes compile ok . I read that instead of comma seperating the classes it might be better to put them in a package but I do not know the correct syntax or where to put the package if this is correct.
    The tutorial is from this book and the shopping cart source code is here.
    http://www.ineasysteps.com/books/?1840781971
    Any help appreciated
    Jim Ascroft

    A little beginners explanation of classpaths and packages is in order here. A package works like an extension of the name to keep class names unique. For example, if you have a ShoppingBasket.class and you want to use my ShoppingBasket.class along with it the two class names must be unique or different from one another in some way. Yours could be in com.yourcompany package and mine could be in org.mycompany package. When you reference you Shopping backet in your code you would use com.yourcompany.ShoppingBasket and when you reference mine in the same code you would use or.mycompany..ShoppingBasket. Shorthand for the class can be used by adding an import at the top of the referencing java file. An import is like saying "hay compiler, whenever you see ShoppingBasket look for it in the com.mycompany package!" That brings us to the next point. The package name must always be reflected in the directory structure of the .class file location in order to be found. Your shopping basket must be stored under the directory com/yourcompany if it is in package com.yourcompany. That directory structure should extend off of a classpath entry in order to be made available to the JVM. Classpath entries point to folders, jar or zip files that contain packaged and unpackaged classes. So If you have a classpath entry that points to C:\jakarta-tomcat-4.1.30\webapps\ROOT\WEB-INF\classes then all unpackaged classes (classes compiled from a .java file without a package statement) will be pulled directly out of this folder. Also, packaged classes will be pulled out of they're packaging directory structure, which should be located in this folder. You can have as many classpath entries as you want but the classes will be pulled out of the first entry that they can be found under. Now with a web app you don't normally fuss with the setting of classpaths since they are already predefined and configured for you. You just need to know to put all of your class files under the WEB-INF/classes directory in the root of your web app. You do, however, still need to know how they work. You also should know that any jar files should be placed in the lib folder of your web app and not under the classes folder.
    Getting back to your immediate problem, why are you getting class not found errors? Well this stems from what was said above. To fix these kind of problems follow these steps:
    1st off, find out exactly which .java file the .class file was compiled from. (This can be a problem in some environments where multiple copies of source hang around.) This step may involve a recompile and paying close attention to the compiler arguments. In an IDE there should be a setting or dialog that lets you find out exactly where it's placing the .class files created from you source.
    Next, determine what package the .class file should be in by examining (and maybe changing) the package statement at the top. For example, if you intended to put ShoppingBasket in the com.bloodoo package make sure it has a package "com.bloodoo;" statement at the top.
    Next recompile the .java source and move the packaging directory structure into the classes folder of your app. (This would be WEB-INF/classes under the root of the web-app.) For example if ShoppingBasket.class was compiled into the com/bloodoo folder under C:\Program Files\YourIDE\projects\yourproject\output then copy the com folder out of the output folder and into the WEB-INF\classes folder.
    Next examine the calling code (JSP or servlet .java code) and make sure it references the problem class out of the right package. For example, yourpage.jsp should reference the class com.bloodoo.ShoppingBasket and not ShoppingBasket if the shopping basket is deployed in package com/bloodoo. This gets tricky with jsp usebean tags because the desire is to use shorthand but I'm not sure if that works with the use bean tag. Make any modifications and recompile if necessary.
    Lastly, as a rule of thumb avoid wild-card imports (eg. import com.package.*) because they are a common cause of confusion especially when refactoring package names and resolving these kind of issues.Those steps should allow you to resolve 85-90% of your class not found issues. The other 10-15% are rare cases involving the use of custom classloaders, the Java extension mechanism and/or classpath trickery. If you still have questions/problems post back.
    Cliff

  • Wrong import warning on JSP page

    I've installed NitroX (v/2.0.0 build 371) and started to use it on an existing project. On a JSP page I got a warning: "The import java.io is never used" from the directive:
    <%@ page buffer="1024kb" autoFlush="true" import="java.util.*, java.io.*"%>
    [/code:1:77aea7b6d7]
    After removing the import, i.e. changed the above to:
    [code:1:77aea7b6d7]
    <%@ page buffer="1024kb" autoFlush="true" import="java.util.*"%>
    [/code:1:77aea7b6d7]
    The warning doesn't disappear. Looking at the properties for the warning I can see that it is 3 days old (creation time = [i:77aea7b6d7]March 18, 2005 11:22:21 AM[/i:77aea7b6d7] vs. today=[i:77aea7b6d7]March 23[/i:77aea7b6d7])
    Is this a bug or do I need to recompile (or similar). I tried to rebuild the Nitrox db, without any effect.
    Rgds and thanks
    Esge                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Check the Resource column of "Problems View" for the warning it will display the file in which you need to correct.
    This warning is from eclipse and displayed for a .java file

  • Directive page import

    pleze
    can i import all packages in java api with directive page import ?
    <%@ page import="anypackage" %>
    or just some packages and if it , what are these packages can i import ?
    thanx

    The JSP import works just like a Java import. You can import everything in a directory, non-recursively.
    E.g.:
    <%@ page import="java.awt.*" %>
    Gets all of the imports under java/awt/, e.g. "java.awt.LayoutManager". But if you need an AWT event, such as "FocusEvent", then you have to go down one more layer, e.g.:
    <%@ page import="java.awt.event.*" %>
    You can repeat the "page import" as many times as you need to import the classes you're using.
    Hope that answers the question?

Maybe you are looking for