2 c:import   in one Jsp Page

Hi all,
I wondering can a jsp page have 2 <c:import> statement?
i having an error which is
"javax.servlet.jsp.JspException: Cannot forward a response that is already committed" when i doing it.
what i want to do is something like:
<c:import url="/student/profile.view?do=TabDisplayRequest&resultLinkKey=${StudentActionForm.resultLinkKey}" charEncoding="utf-8"></c:import>
<body>
<html-el:form action="/student/exam_result.view">
</html-el:form>
</body>
</html-el:html>
<c:import url="/student/course_mark.view?do=DetailRequest" charEncoding="utf-8"></c:import>
The outcome is only the first import and the middle form displayed. the last import statement was skipped.
and prompt me the following error:
javax.servlet.jsp.JspException: Cannot forward a response that is already committed
at org.apache.taglibs.standard.tag.common.core.ImportSupport.acquireString(ImportSupport.java:324)
at org.apache.taglibs.standard.tag.common.core.ImportSupport.doEndTag(ImportSupport.java:179)
Can some one please give me some consultation on this??
thanks
Regards,
junecello

sorry, but just to make a additional note.
the <c:import > tag library is from JSTL taglib <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
regards,
Junecello

Similar Messages

  • Problem for getting the real path using one servlet and one jsp page

    I have one tomcat machine and several virtual domains. Eahc virtual domain has one realpath in the disc.
    I am using one servlet and one jsp page for using this servlet.
    my purpose is to load, using the servlet , the real path for the domains (eahc domain has its path).
    for this i make this:
    the servlet code is this:
    package utils.ticker;
    import java.io.*;
    import java.io.File;
    import java.io.IOException;
    import java.net.*;
    import java.util.*;
    import java.text.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.Filter;
    import javax.servlet.FilterChain;
    import javax.servlet.FilterConfig;
    import javax.servlet.ServletContext;
    import javax.servlet.ServletException;
    import javax.servlet.ServletRequest;
    import javax.servlet.ServletResponse;
    public class Edicion extends HttpServlet{
    public Edicion() {
    public String cc(){
    ServletContext myContext= getServletContext();
    String abspath = myContext.getRealPath("/");
    //here i want to return the real path
    return abspath;
    public static void main(String args[]){
    and the jsp page is:
    <%@ page import="utils.ticker.*" %>
    <jsp:useBean id="tick" class="utils.ticker.Edicion" scope="session"/>
    <html><head><body>
    <%
    tick.cc();
    %>
    </body></head></html>
    But this produces one error, NullPointerException and dont shows me the real path.
    Can anyone help me?
    thanks

    i have put this into one sevlet:
    package utils.ticker;
    import javax.servlet.ServletContext;
    public class Edicion{
    private ServletContext myContext;
    public Edicion(ServletContext myContext) {
    this.myContext = myContext;
    public String getCC(){
    return myContext.getRealPath("/");
    and in the jsp page this:
    <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*"%>
    <%@ page import="utils.ticker.*" %>
    <jsp:useBean id="tick" class="utils.ticker.Edicion" scope="session"/>
    <html><head><body>
    <%=tick.getCC()%>
    </body></head></html>
    but appear this error in the tomcat.
    Can you, please, help me. i am trying to solve this during one week and i am desesperate.
    Thanks.
    ERROR:
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: class utils.ticker.Edicion : java.lang.InstantiationException: utils.ticker.Edicion
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:248)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
         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:2415)
         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:432)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530)
         at java.lang.Thread.run(Thread.java:536)
    root cause
    javax.servlet.ServletException: class utils.ticker.Edicion : java.lang.InstantiationException: utils.ticker.Edicion
         at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:533)
         at org.apache.jsp.pruebas_jsp._jspService(pruebas_jsp.java:72)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:204)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
         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:2415)
         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:432)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530)
         at java.lang.Thread.run(Thread.java:536)
    Apache Tomcat/4.1.18

  • Can I create multiple instances of  realplayer plug-in in one jsp page?

    I want to play meny video files in one jsp web page, these video files are to be played with the embeded plug-in of realplayer, each plug-in was linked(use its SRC property) a different video file. But, to my surprise, when I press the play button, every player played the same video file,not its specified file.
    I have no idea why it did so and what can I do?
    Whether can I create multiple instances of realplayer plug-in in one jsp page, that is to say, each instance is independent of others?
    thanks in advance!

    Generally speaking, Internet Explorer tries not to launch multiple versions of a plug-in. So what's happening is that you load the first video clip, and then before it has a chance to play, you load the second video clip into the same window. (It's like changing songs in WMA.)
    In some cases - this may not work for Real Player, but it's worth trying - if you spawn a new window through a hypertext link and then launch the plug-in in that window, IE will treat it separately. Otherwise, you could not, for example, run two Macromedia Flash applications from different web sites at the same time.
    Keep in mind that only one program can access the soundcard at a time, so Real Player may purposely "pause" or "cancel" other video streams until the active one finishes. If you were using the desktop version, selecting another video by any means aborts the currently running video (i.e., RP won't let you create a separate instance of it).
    The easiest solution is to create a wrapper JSP file that takes the name of the video clip, and plays it. Call that JSP and specify that it should be opened in a new window via the TARGET keyword in the anchor tag. Then hopefully RP itself won't block a second window from running.

  • How to display result in more than one jsp page

    Hi all,
    the result is a very large it will take more than one jsp page in this senario how we will display the result in more than one jsp page.
    Thanks in Advance.

    The magic word is "paging". Look around using this keyword.
    Basically it's all about subquerying, (eventually) caching and sublisting.

  • How to get the value in one JSP page to another?

    Hi,
    I have problems in passing the value around in JSP. I have two JSP pages as below:
    test1.jsp
    I try to get the vaule from my textbox by using:
    String strUser = request.getParameter ("strUserName");
    Then i print out by using: out.print(strUser); then i can get the value and put on my page (For example, i get ABC on my page).
    test2.jsp
    Next, i want to get the value from strUser (which mean that the one i already display on page in test1.jsp, ABC) to insert into my table by using INSERT INTO statement. Then i try by using
    String strUser1 = request.getParameter ("strUser");
    Is it possbile for me to do that? I cannot get anything to insert into my table. Then i tried out.print(strUser1); then i found that i get NULL value.
    Could you please give me some guidance?
    Thanks you very much for any advise you may give me.
    Kimsan

    Hi,
    Thank you very much for your help. It's working fine if i just get a one value to another page, however, i have problem while i pass the value in my loop to another page because i always get the last record. I try with the following code:
    logged_page.jsp
    <html>
    <head>
    <title>Welcome to the online Auction...</title></head>
    <body>
    <%@ page language ="java" import = "java.io.*, java.lang.*, java.sql.*" %>
    <% try
         String strUsername = request.getParameter("username");
         session.setAttribute("myUserName", strUsername);     
         String strPassword = request.getParameter("password");
         Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
         Connection myConn = DriverManager.getConnection("jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ=C:/Auction/Auction.mdb");
         String strSQL = "SELECT [UserName], [Password] FROM tblUserDetails where [UserName] = ? and [Password] = ?";
         PreparedStatement statement = myConn.prepareStatement(strSQL);
         statement.setString(1, strUsername);
         statement.setString(2, strPassword);
         ResultSet myResult = statement.executeQuery();
         if(myResult.next())
         //out.println("Login Succesful! A record with the given user name and password exists");
         out.print("<center><h1>");
         out.print("Welcome  ");
         out.print(strUsername);
         out.print("</h1></center>");
         out.print("<center>");
         out.print("<BR><BR>");
         out.print("<font font face = Viner Hand ITC size= 5>Products on sales</font>");
         out.print("<BR><BR>");
         Statement myStatement = myConn.createStatement ();
         ResultSet myResult1 = myStatement.executeQuery("SELECT * FROM tblProduct");
         ResultSetMetaData myResultSet = myResult1.getMetaData();
         out.println("<font face=Tahoma>");
         out.print("<table border=1 CELLSPACING=0>");
         out.print("<TR>");
         out.print("<TD width = 200> Item Title");out.print("</TD>");
         out.print("<TD width = 200> Description");out.print("</TD>");
         out.print("<TD width = 200> Current bid");out.print("</TD>");
         out.print("<TD width = 200> Available Time");out.print("</TD>");
         out.print("<TD width = 200> Place Bid");out.print("</TD>");
         out.print("</TR>");
         out.print("</table>");
         while(myResult1.next())
              String strProName = myResult1.getString(1);
              session.setAttribute("myProName", strProName);          
              out.print("<table border=1 CELLSPACING=0>");
              out.print("<TR>");
              out.print("<TD width = 200>");
              out.println(strProName);
              out.print("</TD>");
              out.print("<TD width = 200>");
              out.println(myResult1.getString(3));
              out.print("</TD>");
              out.print("<TD width = 200>");
              out.println(myResult1.getString(2));
              out.print("</TD>");
              out.print("<TD width = 200>");
              out.println(myResult1.getString(4));
         out.print("</TD>");
         out.print("<TD>");
              out.print("<form action=bid_page.jsp method=post>");
              out.print("<input type=text name=place_bid>");
              out.print("<input type=submit name=okfunc value=Bid>");
              out.print("</TD>");
              out.print("</form>");
              out.print("</TR>");
              out.print("</table>");
              out.println("</font>");
              out.print("</center>");          
         else
              out.print("<center>");
              out.print("Sorry ");
              out.print("<font color = RED size = 5>");
              out.print(strUsername);
              out.print("</font>");
              out.print(" could not be found.");
              out.print("</center>");
         myResult.close();
         statement.close();
         myConn.close();
         catch(SQLException e)
         out.println(e);
    %>
    </body>
    </html>
    bid_page.jsp
    <HTML>
    <HEAD>
    <TITLE>Welcome to the online Auction...</TITLE>
    </HEAD>
    <BODY>
    <%@ page language ="java" import = "java.io.*" import = "java.lang.*" import = "java.sql.*" %>
    <% try
         String thisUserName = (String) session.getAttribute("myUserName");
         String thisProName = (String) session.getAttribute("myProName");
              Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
         Connection myConn = DriverManager.getConnection("jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ=C:/Auction/Auction.mdb");
         PreparedStatement myStatement = myConn.prepareStatement("INSERT INTO tblHistory VALUES ('"+thisUserName+"', '"+thisProName+"', '"+request.getParameter("place_bid")+"')");
              myStatement.executeUpdate();
              myConn.commit();
              myStatement.close();
              myConn.close();
              catch(Exception e){}
    %>
    </BODY>
    </HTML>
    When i click on the BID button in the logged_page.jsp then i always get the last record and save into my table and that is not what i want to. i want to get the result on the same row as the BID button that just click and save to my table.
    Could you please advise?
    Thanks you very much for your time and any consideration you may give me.
    Best Regard,
    Kimsan

  • 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

  • Problem in passing data from one .jsp page to another .jsp page

    i have a problem here
    Actually i have 2 jsp pages. What im trying to do here is actually i want to pass data from the first jsp page to the second for updating
    The first jsp page contains data that user wants to update in the form of table.
    <td><img src = "edit.gif" alt = "edit" border="0" ><td>
    <TD><%= Name %></td>
    <TD><%= rs.getInt("Age") %></td>
    <TD><%= rs.getString("Gender") %></td>
    So this page displays the data that users wants to update plus one image button (edit button). So when user clicks this button, all the data in this page will be brought to the second .jsp page called updatePersonal for updating.
    The problem here is that it is not displaying the existing data in the second .jsp page.
    The second page basically contains forms
    <INPUT TYPE="text" NAME="FirstName" maxlength="30" value = "<%=FirstName%>">
    Can someone please help me. I really dont know what to do..How do i get the data displayed in the text field that is passed from the first .jsp page..thankx in advance

    Please modify below code to:
    td><img src = "edit.gif" alt = "edit" border="0" ><td>
    -----------------modified code
    td><a href="updatePersonal.jsp?FirstName=<%=rs.getString(FirstName")%">&LastName=<%=rs.getString("LastName")%>&Age=<%=rs.getInt("Age")%>&Gender=<%=rs.getString("Gender")%>"><img src = "edit.gif" alt = "edit" border="0" ></a><td>
    I'm sure it works</a>

  • How to submit two forms once  in one jsp page?

    hello all,
    My jsp page includes two forms: one form's action is a File Upload servlet, which process file uploading; another is a general servlet to collect user inputs, such as user name, age, etc.
    Because the file upload servlet is a legacy component, and it was used in many applications. we could not meger it into our business components.
    the system requires the file upload and information collection are submitted once. so we have to submit two forms in one 'Submit' action, at the same time, the information collection servlet need get the information from file upload servlet, such as the uploaded file's url.
    I have tried two methods, but all failed
    1. Upload form has no a 'Submit' button, when user click the 'submit' button of the information collection form, we use a javascript to submit upload form first, then submit information collection form. Failed at: the second submit dose wait for upload finishing, then the second submit interrupt the upload
    2. the javascript only submit upload form, and set HTML body's onUnload event to another javascript that submit information collection form. this time, the file upload sucess, and information collection form sucess at most time. But fail when user click the 'refresh' or 'back' or any navigator buttons of the browser. these action will trigger the page 'unload' event too, but the submit if invalid!
    Please tell me how to.

    chain the both requests!
    - build one mutlitpart request and send it to a servlet that can handle that multipart request (think of using oreilly MultiPartParser).
    - check the input (all requiered fields and files there)
    - if yes store the user fields and create a socket connection from your servlet to the legacy file upload servlet and post the file this way.
    - like this you have full control over the users input and can make sure the file and the fields are just save if all requiered elements are availble.

  • How do i update a db table using one JSP page

    I created a JSP Form page and I want to update a db table when the user hit submit. Please help my job depends on it Send me small code example below is what I have (very new to JSP)
    <%@ page language="java" import="java.sql.*" import="java.io.*" %>
    <html>
    <head><title>accessing database</title></head>
    <body bgcolor="white">
    <%     Connection con =null;
         try {
    // Load Driver Class File
         Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    //Make a connection to Data table
    con = DriverManager.getConnection("jdbc:odbc:SportsbookTables", "developer", "developer");
    Statement statement =con.createStatement();
    String SQL = new String("INSERT INTO tblLines (gameID,leagueType) VALUES (5,'gam')");
    statement.executeUpdate(SQL);
    statement.executeUpdate("INSERT INTO tblLines (gameID,leagueType) VALUES (6,'lea')");
    %>
    <table border=1 cellspacing=1 cellpadding=1>
    <form method="POST">
    <p><font color="#800000" size="5">Enter your name:</font><input name="leagueType" size="4"></p>
    <p><input type="submit" value="Submit"></p>
    </form>
    <%
    catch (IOException ioe)
    out.println("IO Exception:");
    out.println(ioe.getMessage());
    catch (SQLException sqle)
    out.println("SQL Exception:");
    out.println(sqle.getMessage());
    catch (ClassNotFoundException cnfe)
    out.println("Class Not Found Exception:");
    out.println(cnfe.getMessage());
    catch (Exception e)
    out.println("General Exception:");
    out.println(e.getMessage());
    finally {
    try
    if (con!=null) {
    con.close();
    catch(SQLException sqle)
    out.println(sqle.getMessage());
    %>
    </table>
    </Body>
    </HTML>

    First I would remove all the JDBC code you have in the JSP and place it in a servlet (or other Java) class, and have your form action call the servlet on submission. Then use the servlet API to extract the form data from the request and pass it to the JDBC in the servlet to update the DB. Once complete have it branch to another JSP/HTML to let the user know if they were successful or not.
    Take a look at some of the online tutorials as they will be helpful with regards to code examples.
    Depending on the size of your project, and deadlines naturally, you may also want to have a look at an MVC architecture and custom tags like Struts from Apache. These can make your job a lot eaiser.

  • 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

  • Applet loads in one jsp page and doesn't in the other

    Hi,
    I've got a strange problem. I've written an applet which I want to embed in a jsp page in a web application. I've created a very small web application to simplify testing the applet, and all works well in it. But when I try to embed the applet in my real web application (exactly the same way) it fails to init, firefox hangs, and in java console I get;
    java.lang.ClassFormatError: Incompatible magic value 168430090 in class file pl/cardq/applet/GameApplet1
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
    at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:178)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:127)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:618)
    at sun.applet.AppletPanel.createApplet(AppletPanel.java:778)
    at sun.plugin.AppletViewer.createApplet(AppletViewer.java:2045)
    at sun.applet.AppletPanel.runLoader(AppletPanel.java:707)
    at sun.applet.AppletPanel.run(AppletPanel.java:361)
    at java.lang.Thread.run(Thread.java:619)
    Any idea what that means?
    Thanks in advance

    Once the print window is open, click on "PDF", in the list of options you will find "open PDF in Preview".
    (I hope my translation is good because I am using French...)

  • Passing an array from one jsp page to another.

    I need to pass an array from one page to another, without using the query string.
    Can anyone help?
    I was given one suggestion about putting the array inside a Map object, then putting the map in the session.
    Is there an alternative? i am struggling to find out how to use maps properly.
    Alternatively, could someone give me a pointer on how to implement this possibility?
    Help needed ASAP.
    Thankyou

    First.jsp
    String[] str = {1,2,3,4,5};
    session = request.getSession(true);
    session.setAttribute("str",str); //or application.setAttribute("str",str);
    Second.jsp
    session = request.getSession();
    String str[] = (String[])session.getAttribute("str"); //or String str[] = (String[]) application.getAttribute("str");
    Now you can use str[].
    Sudha

  • Jsp Page session vaiable to java class and vise versa

    Hi to all,
    I am new to jsp, i have to programs, one jsp page and another java class. in jsp page i get the user data from html form and put the id in session. here i have to call the session vaiable to my java class where it (variable)initialize a file name.
    and same i have to call the java class to jsp page which insert statements to sql server,
    Please Help Me.

    //My Java Class file
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    import javax.servlet.http.HttpSession;
    import java.sql.Statement;
    public class StuInfo extends Object {
    //main method begins execution of Java application
    public static void main (String args[]){
    String StuFile = "C://"+iD+".txt"; // Here i have to get the session varaible.(ID)
    try {
    In my jsp Page i initilized session as
    session.setAttribute("ID",StuId);
    I am not able to understand where i have to declear the HTTPSession#getAttribute("ID");

  • JSP page "cannot resolve symbol"

    Hi,
    I'm using j2sdk1.4.2_01 and tomcat-5.0.13. I'm developing within Eclipse 3.0.0 with the Tomcat plugin.
    In my project ("Agenda2") i only created one class ("Persona"), that is correctely compiled (%TOMCAT_HOME%\webapps\Agenda2\WEB-INF\src\Persona.java results in %TOMCAT_HOME%\webapps\Agenda2\WEB-INF\classes\Persona.class, and 0 problems are shown in the Problems list.
    In %TOMCAT_HOME%\webapps\Agenda2 i have my Edit.jsp, that begins with these lines:
    <%@ page language="java" contentType="text/html" %>
    <HTML>
    <HEAD>
    <TITLE>Edit</TITLE>
    </HEAD>
    <BODY>
    <jsp:useBean id="personaAtt" class="Persona">
        <jsp:setProperty name="personaAtt" property="*" />
    </jsp:useBean>
    ....When i call the JSP from the browser, i get this error:
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: 8 in the jsp file: /Edit.jsp
    Generated servlet error:
        [javac] Compiling 1 source file
    C:\Programmi\Java\tomcat-5.0.13\webapps\Agenda2\work\org\apache\jsp\Edit_jsp.java:48: cannot resolve symbol
    symbol  : class Persona
    location: class org.apache.jsp.Edit_jsp
          Persona personaAtt = null;
          ^The error message mentions line 8, which is the one following <BODY>, that is
    <jsp:useBean id="personaAtt" class="Persona">My impression is that there is some path problem, but despite my tries i can't get it.
    The folders tree under %TOMCAT_HOME%\webapps\Agenda2\ is:
    -WEB-INF
    --classes
    --lib
    --src
    -work
    --org
    ---apache
    ----jspDoes anybody can see the problem ?

    Thanks! I'm going to try to put the class into a package as both you have suggested, and i'll post here the result.
    In the meantime i have a related newbie question:
    putting the class into a package, is this kind of a workaround, or it's the "normal thing" ?
    I mean, is it mandatory to put classes into a package in order to import them from JSP pages ?
    It was my understanding that it isn't mandatory, but - from your replies and many other posts in this forum - i'm starting to think that i'm wrong.

  • Problem while i am sending image as a stream between jsp pages

    Hi,
    I want to send the image from one jsp page to another jsp via stream.
    Help to continue the process...

    Thak you for ur reply.
    But in Servlet-Chaining concept, one servlet output stream passed to another servlet and goes on...
    like that, is possible to do same in jsp.
    My actual task is to send the image from one jsp page to another, the sample code i paste here
    <%@ page import="java.io.*" autoFlush="true" %>
    <%
    System.out.println("======Send.jsp=====");
               ServletContext sercon = getServletContext();
                 String filename = sercon.getRealPath("/logo.png");
         RequestDispatcher rd = sercon.getRequestDispatcher ( "/read.jsp" ) ; 
         InputStream file=new BufferedInputStream(new FileInputStream(filename));
         int i,j=0;
                      try
              OutputStream os=response.getOutputStream();
              while((i=file.read())!=-1)
                   j++;
                   os.write((byte)i);
    System.out.println("Bytes Read : "+j);
         rd.forward(request,response);
              os.flush();
              file.close();
         catch(Exception e)
              System.out.println("Error"+j);
    %>
    <%@ page import="javax.swing.*,java.io.*,java.util.*"%>
    <%            
         byte[] by;
         int i,j=0;
    System.out.println("======Read.jsp=====");
         response.setContentType("image/png");
         InputStream is=request.getInputStream();
    System.out.println("In Read.jsp read bytes : "+is.available());
         ByteArrayOutputStream os=new ByteArrayOutputStream();
         while((i=is.read())!=-1)
              j++;
              os.write(i);
         by=os.toByteArray();
         out.println(by+"\n"+i);
         os.close();
         is.close();
    %>If i run this code (send.jsp) the image is displayed in the current page itself, and not forward to read.jsp
    Is any other alternative solutions then point out.

Maybe you are looking for