Jsp/jdbc - Tomcat

My requirement is once i issue a request from my jsp (the request is a sql query) it has to hit the database and should
return the number of affected row but should not commit it . In the next request from jsp the user will either hit
commit button or rollback button and based on the request it will either commit or rollback .In order to acheive this i
believe i have use the same connection object for both request.
I know http is stateless and i have to use the same connection object for both the request .
1) How can i use the same connectionobject in both request.?
2) What if the user did not click commit or rollback button . How can i expire the connection object that was opened during first request

I think you might want to read up on this on google:
optomistic concurency sql
I think the best solution is to get/use/close your connection as fast as possible (in a try/catch/finally block) within the same function.
In your database table, add a new column called 'version'. Each time someone updates a record in the table, increase the value of version by one for that record.
Now, in your design, read the record (including version number), display it to the user. Later, when the user clicks the update button, see if the version number has changed when you go to update.
If so, inform the user that the record has changed in the meantime. Usually, end users work on different records and seldom the same record at the same time so the collision doesnt occur often.
Example
sql= update person set firstName='john' where person_id=434 and version=34
The above will return a value of '1' if it was updated, '0' if it wasn't.
Note there is no need to rollback with this method.
Transaction advice:
Use a transaction if:
1) You are updating/inserting/deleting more than one record in a table and need to rollback if any one record update/insert/delete fails (or the version number shows it was changed per the above example).
2) you need to query one table and update the same table or some another table and want to ensure no records were changed between the query and update (treat them as an atomic operation).
3) you need to create more than one query to query several tables and want to ensure no data was changed in any table while doing the queries.
No tranaction if:
1) you query more than one table using one sql statement (a join).
See also database section at http://www.javapractices.com/home/HomeAction.do

Similar Messages

  • Problem with JNDI and JSP in Tomcat

    Hi,
    Basically, what I've done is to use the Tomcat administration web
    application to create the DataSource, which looks like it populated the
    server.xml (see below). I then try to access the testconn.jsp, and am
    getting that "Name java:comp is not bound in this Context" error.
    I was wondering if anyone could tell me what I'm doing wrong?
    Thanks,
    Feri
    My Configuration:
    - Tomcat 5.0.19
    - MySQL 4.0.18-nt
    - mysql-connector-java-3.0.15-ga-bin.jar
    server.xml:
    <GlobalNamingResources>
    <!-- Test entry for demonstration purposes -->
    <Environment name="simpleValue" type="java.lang.Integer" value="30"/>
    <!-- Editable user database that can also be used by
    UserDatabaseRealm to authenticate users -->
    <Resource name="UserDatabase" auth="Container"
    type="org.apache.catalina.UserDatabase"
    description="User database that can be updated and saved">
    </Resource>
    <ResourceParams name="UserDatabase">
    <parameter>
    <name>factory</name>
    <value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
    </parameter>
    <parameter>
    <name>pathname</name>
    <value>conf/tomcat-users.xml</value>
    </parameter>
    </ResourceParams>
    <!--Feri test JNDI-->
         <Context crossContext="true" debug="5" docBase="injury" path="/injury" reloadable="true">
         <Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_injury_log." suffix=".txt" timestamp="true"/>
              <Resource name="jdbc/injury" auth="Container"
    type="javax.sql.DataSource">
    </Resource>
    <ResourceParams name="jdbc/injury">
         <parameter>
              <name>factory</name>
              <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
         </parameter>
    <parameter>
    <name>username</name>
    <value>root</value>
    </parameter>
    <parameter>
    <name>password</name>
    <value>root</value>
    </parameter>
         <parameter>
    <name>driverClassName</name>
    <value>com.mysql.jdbc.Driver</value>
    </parameter>
         <parameter>
    <name>url</name>
    <value>jdbc:mysql://localhost:3306/injury</value>
    </parameter>
         <parameter>
              <name>maxIdle</name>
              <value>30</value>
         </parameter>
         <parameter>
              <name>maxActive</name>
              <value>10</value>
         </parameter>
         <parameter>
              <name>maxWait</name>
              <value>10000</value>
         </parameter>
    </ResourceParams>
         </Context>
    <!--Feri test JNDI end-->
    </GlobalNamingResources>
    \webapps\injury\WEB-INF\web.xml:
    <resource-ref>
    <description>Resource reference to a factory for java.sql.Connection instances that may be used for talking to a particular database that is configured in the server.xml file.</description>
    <res-ref-name>jdbc/injury</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>
    \webapps\injury\testconn.jsp
    <%@ page import="java.sql.*" %>
    <%@ page import="javax.sql.*" %>
    <%@ taglib prefix="ct" uri="/injury" %>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
    <h1>Connection test</h1>
    <ct:connection name="jdbc/injury">
    <%
    Statement stmt= conn.createStatement();
    ResultSet rs;
    rs = stmt.executeQuery("select * from user");
    while (rs.next()){
    %><%=rs.getString(1)%><%=rs.getInt(2) %><br><%
    rs.close();
    stmt.close();
    %>
    </ct:connection>
    ConnectionTag.java
    import java.io.*;
    import java.sql.*;
    import javax.servlet.*;
    import javax.servlet.jsp.*;
    import javax.servlet.jsp.tagext.*;
    import javax.naming.*;
    import javax.sql.*;
    import javax.sql.DataSource;
    public class ConnectionTag extends TagSupport implements TryCatchFinally {
    private Connection conn;
    // JNDI name of the connection
    private String name;
    public void setName(String name)
         this.name = name;
    public int doStartTag()
         throws JspException
         try {
         Context env = (Context) new InitialContext().lookup("java:comp/env");
         DataSource ds = (DataSource) env.lookup(name);
         if (ds != null)
              conn = ds.getConnection();
         } catch (Exception e) {
         throw new JspException(e);
         if (conn == null)
         throw new JspException("can't open connection " + name);
         pageContext.setAttribute("conn", conn);
         return EVAL_BODY_INCLUDE;
    public void doCatch(Throwable t)
         throws Throwable
         throw t;
    public void doFinally()
         try {
         Connection conn = this.conn;
         this.conn = null;
         pageContext.removeAttribute("conn");
         conn.close();
         } catch (Exception e) {
    Tomcat 5.0\conf\Catalina\localhost\injury.xml
    <?xml version='1.0' encoding='utf-8'?>
    <Context displayName="Injury" docBase="E:\Tomcat 5.0\webapps\injury" path="/injury" className="org.apache.catalina.core.StandardContext"
    cachingAllowed="true" charsetMapperClass="org.apache.catalina .util.CharsetMapper" cookies="true" crossContext="false" debug="0"
    mapperClass="org.apache.catalina.core.StandardContextMapper" useNaming="true" wrapperClass="org.apache.catalina.core.StandardWrapper" >
    <Resource auth="Container" description="Resource reference to a factory for java.sql.Connection instances that may be used for talking to a particular database that is configured in the server.xml file." name="jdbc/injury" type="javax.sql.DataSource"/>
    <ResourceLink global="jdbc/injury" name="injury" type="javax.sql.DataSource"/>
    </Context>

    Hi,
    First of all, you can find alot of information about this in the forum about jsp's.
    I think a good thing to do is not to put your context tag directly into the server.xml file.
    What you should do is create a context.xml file with the context-tag in it, and put it in the META-INF directory of your .war file. Upon deployment to tomcat5 this file will be extracted from the war, copied to the conf\enginename\hostname directory, and it will be renamed to contextName.xml.
    I think you are developing directly into the webapps directory, and I believe you should avoid that and use the deployment feature of the manager web-app or you should use the deployertool from you ide or standalone ant.
    anyway, for starters try to remove the context tag from the server.xml file as described above, and check out the jsp / jdbc forums for simular problems and answers.
    good luck

  • Oracle Connectivity in JSP using Tomcat 4

    Dear friends,
    After installing and configuring the Tomcat 4 I am able to run JSP and Servlats. But I am unable to connect to Oracle database (oracle 8i) using thin driver.
    Sample code is :
    <html>
    <head><title>Test JSP-JDBC</title></head><body>
    <%@ page language="java"%>
    <%@ page import="java.sql.*"%>
    <%@ page import="oracle.jdbc.driver.OracleDriver" %>
    <%
    try
    DriverManager.registerDriver(new OracleDriver());
    Connection con = DriverManager.getConnection("jdbc:oracle:thin:@myserver:1521:orcl","scott","tiger");
    Statement stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery("select * from emp");
    while(rs.next())
    out.println(rs.getString("ename")+"<br>");
    catch (Exception e)
    out.println(e);
    %>
    </body></html>
    and the error msg is:
    type: Exception report
    message: Internal Server Error
    description: The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.
    exception :
    org.apache.jasper.JasperException: Unable to compile class for JSP
    C:\Program Files\Apache Tomcat 4.0\work\Standalone\localhost\second$jsp.java:4: Class oracle.jdbc.driver.OracleDriver not found in import.
    import oracle.jdbc.driver.OracleDriver;
    ^
    1 error
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:285)
    at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:548)
    Please help me in solving this.
    thanks in advance
    Geethanadh

    Hi
    The oracle driver needs a jar file to be placed into your Runtime Environment. If you are importing oracle. Get the jar file, put it in your JRE/lib/ext folder and also in the jdk/jre/lib/ext folders. Restart your tomcat, and now try to compile the page. Should work.
    Thanks
    Swaraj

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

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

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

  • Help running a simple jsp file,Tomcat 5.0.16

    Hi,
    This question may be addressed many many times,but do reply.
    I have a Win xp operating system
    Installed Tomcat 5.0.16 in it.
    Next the directory structure
    PS : The sampleapp directory is outside the tomcat installation directory.
    E:/sampleapp
    | |
    ROOT WEB-INF
    |
    classes
    |
    <package1><structure> .class files (for servlet works fine!!!!)
    in the WEB-INF,there is the web.xml,then sourcefiles<dir> and the lib directory which is empty.
    Now the servlet files work fine.........
    I have placed my MyJsp.jsp file in the above mentioned ROOT directory.
    I have not done any thing with the <TOMCAT_HOME>/conf/server.xml file
    and the web.xml which I have written.
    When I give the following URI
    http://localhost:8080/sampleapp/MyJsp.jsp,
    I get the HTTP status 404- /MyJsp.jsp
    description: The requested resource (/MyJsp.jsp) is not available.
    Hoping that I have defined the problem specifically.Kindly show some light on this.
    Thanks
    AS

    Nevermind. I just found the answer. For the record, there are two ways in getting JSPs to work:
    1. Precompiling the JSPs and modifying your webapp's web.xml file with the XML fragment generated in YourWebApp/web/WEB-INF/generated_web.xml;
    2. Not precompiling the JSPs, but simply letting tomcat compile it on the fly on first access.
    PRECOMPILATION METHOD
    Go to http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jasper-howto.html. Copy-and-paste the ant script under the section "Web Application Compilation" into a file called compile.xml. For me, I save it in ~/development/compile.xml. Then compile the JSPs using the command (all in a single line):
    $ANT_HOME/ant -file <PATH_TO_COMPILE.XML> -Dtomcat.home=<$TOMCAT_HOME> -Dwebapp.path=<$WEBAPP_PATH>
    In my case, I cd into the directory where my app resides:
    cd ~/development/HelloWorld
    and then I type:
    ant -file ~/development/compile.xml -Dtomcat.home=/var/tomcat5 -Dwebapp.path=.
    (Note the trailing dot since my current directory is my webapp's directory itself. Also, in my case, my shell's PATH contains the path to the ant executable, so I just type 'ant' directly.)
    Open the file ~/development/HelloWorld/web/WEB-INF/generated_web.xml and follow the instructions in that auto-generated file, which is: "Place this fragment in the web.xml before all icon, display-name, description, distributable, and context-param elements."
    The web.xml referred to above is YOUR web.xml. In my case, it is the one in ~/development/HelloWorld/web/WEB-INF/web.xml
    When ready to deploy, type:
    ant dist
    as usual. Deploy the .war file in the dist directory as you normally would. In my case, I do:
    rm -rf $CATALINA_HOME/webapps/hello* (removes my HelloWorld webapp directory and its war file)
    cp ~/development/HelloWorld/dist/hello.war $CATALINA_HOME/webapps
    and wait for tomcat to unravel the war file. I can then access the JSP page based on whatever the generated_web.xml had specified. In my case, it would be http://localhost:8080/hello/sample.jsp
    NON-PRECOMPILATION METHOD
    Copy tools.jar from the Java JDK into tomcat's common/lib. (I found this only in the error message in tomcat's log file!! Didn't find it anywhere else!!). Do this one time only, then restart tomcat:
    cp $JAVA_HOME/lib/tools.jar $CATALINA_HOME/common/lib
    Restart tomcat.
    Deploy your webapp as usual which will include your JSP files stored under your webapp's 'web' directory. No precompilation of JSPs is required. Then access your JSP pages such as http://localhost:8080/HelloWorld/my-jsp-page.jsp and tomcat will compile it on the fly on first access. The disadvantage is that there will be a slight delay on first access.
    [Note:  I am putting all this down for the record, because it took me MANY HOURS to figure all this out as the info on how to do this is not found clearly in one place!!  Hope this helps others.]
    My next step is to incorporate the contents of compile.xml as mentioned above, into my regular build.xml file.

  • Problems compiling jsp on Tomcat

    I am getting an error message when I try to run jsp files on the Tomcat server. It runs the txt files fine. Using the 8080 port. Any suggestions about what is going wrong? This is my first time to run jsp or Tomcat on this computer. Thank you. Sorry for the long error message.
    Apache Tomcat/4.0.1 - HTTP Status 500 - Internal Server Error
    type Exception report
    message Internal Server Error
    description The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.
    error: Invalid class file format in C:\Program Files\Java\jre1.5.0_04\lib\rt.jar(java/lang/Object.class).
    The major.minor version '49.0' is too recent for this tool to understand.
    C:\Program Files\Apache Tomcat 4.0\work\localhost\myapp\project3a$jsp.java:0: Class java.lang.
    Object not found in class javax.servlet.GenericServlet.
    package org.apache.jsp;
    ^
    2 errors, 1 warning
         at org.apache.jasper.compiler.Compiler.compile(Compiler.java:284)
         at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:546)
         at org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:177)
         at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:189)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:382)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474)
         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:243)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:201)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2344)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:462)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:163)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1011)
         at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1106)
         at java.lang.Thread.run(Unknown Source)

    It looks like it is running multiple versions of Java.
    It looks like you are trying to run with java 1.5
    Check what your JAVA_HOME variable is set to
    Do you have any other versions of java installed on the machine?

  • Exception notification through Email in JSP and Tomcat 5.5

    Hi,
    I have developed a Web application using jsp on Tomcat 5.5 web server. I want and email sent to myself if any exception occurs on the server side along with the exception.
    I am not sure if it can be done on JSP or its part of Tomcat configuration.
    I hope you guys could help me
    Thank you

    Check this page:
    http://www.imagescript.com/atg/articles/jsp_j2ee/error_page_basics.htm
    That explains how to set your own error page. Inside that jsp you can use the JavaMail api to send the exception as an email.

  • JavaMail & JSP using Tomcat

    Hi all
    I am having a problem installing JavaMail
    I have installed everything, added the mail.jar and activation.jar to my classpath, but when I try to run a JSP I get import errors:
    javax.mail.*, package mail not found etc etc...
    When I try to compile demos in the JavaMail directory, they compile fine.
    Any ideas??
    Thanks
    Matt A

    Your classpath? You need to put those jar files where the JSPs and Tomcat can see them, which I believe means you have to put them in a directory whose name is something like .../WEB-INF/lib.

  • Unable to load Applet in JSP using Tomcat 5.5.12

    Hi
    I am aunable to applet in jsp using Tomcat 5.5.12 and JRE 1.5. Below is the code that I am using
                                       <applet
                                       codebase = "."
                                       archive = "WebPOSApplet.jar"
                                       code = "webposprint.WPMainApplet.class"
                                       name = "Trans Applet"
                                       width = "450"
                                       height = "115"
                                       hspace = "0"
                                       vspace = "0"
                                       align = "middle"
                                       >
    <param name = "redirectInfo" value = "SearchProducts.do">
                                       </applet>
    <%/*%>
    <OBJECT
                                       classid = "clsid:CAFEEFAC-0014-0002-0000-ABCDEFFEDCBA"
                                       codebase = "http://java.sun.com/products/plugin/autodl/jinstall-1_4_2-windows-i586.cab#Version=1,4,2,0"
                                       WIDTH = 450 HEIGHT = 115 >
    <PARAM NAME = CODE VALUE = webposprint.WPMainApplet.class>
    <PARAM NAME = archive VALUE = WebPOSApplet.jar>
    <PARAM NAME = "type" VALUE = "application/x-java-applet;jpi-version=1.4.2">
    <param name = "redirectInfo" value = "SearchProducts.do">
    <PARAM NAME = "scriptable" VALUE = "false">
    <PARAM NAME = model VALUE=models/buckminsterfullerine.xyz>
    <embed width="450" height="115" code="webposprint.WPMainApplet.class" archive="WebPOSApplet.jar" type="application/x-java-applet;jpi-version=1.4.2" redirectinfo="SearchProducts.do" scriptable="false" model="models/buckminsterfullerine.xyz" src="webposprint.WPMainApplet.class">
    </embed> <COMMENT> <EMBED
                                       type = "application/x-java-applet;jpi-version=1.4.2" \
                                       CODE = webposprint.WPMainApplet.class\
                                                 archive = WebPOSApplet.jar\
                                       WIDTH = 373 \
                                       HEIGHT = 167 \
                                       model =models/buckminsterfullerine.xyz \
                                            scriptable = false \
                                            pluginspage = "http://java.sun.com/products/plugin/index.html#download"> <NOEMBED>
    alt="Your browser understands the <APPLET>
    tag but isn't running the applet, for some reason."
    Your browser is completely ignoring the <APPLET>
    tag! </NOEMBED> </EMBED> </COMMENT>
    </OBJECT>
    <%*/%>
    This code doesn't seems working with Tomcat 5.5.12. I works fine with Tomcat 4.1.31
    Please help
    Thanks

    Applets run client side - which means the relevant class files need to be downloaded to the client.
    Anything under the WEB-INF directory is not directly accessible by the client. Nothing under WEB-INF can be downloaded.
    ergo, specifying the WEB-INF directory as part of your applet codebase is a bad idea.
    I would suggest try copying the applet classes from under WEB-INF to some other place in your application.
    Also, you should probably specify the full class name of your Applet in the plugin tag.
    <%@ page import="com.util.MyApplet" %>
    <jsp:plugin type="applet" code="com.util.MyApplet" codebase="/classes" width="250" height="100" jreversion="1.6">
         <jsp:fallback>
              <B>Unable to start plugin!</B>
         </jsp:fallback>
    </jsp:plugin>cheers,
    evnafets

  • Classes and JSPs in Tomcat-4.1.24

    Where to put the class files and how to call them in the jsps in Tomcat-4.1.24.
    <br>In Tomcat-3.2.4 I used to put them in WEB-INF/classes and call them. The same jsp's working in Tomcat-3.x are not working in 4.1.24 version. Any idea???
    Thanx in advance

    Apparently tomcat4.1 requires all class files to be in a package so class files that you just had in WEB-INF/classes need to be re-compiled into packages.
    Then you will need to import these classes into your jsp with a
    <%@ page import= ..../> statement

  • How to run jsp in tomcat server

    hi this is satish1529,
    i am new to jsp technology,i have written small jsp file and html file,i don't know where to place jsp and html files in tomcat server and where i have to do setting in the server and how to run jsp file. pls give me step by step describing how to run jsp in tomcat server.
    i am showing u files
    this is jsp file
    <html>
    <body>
    <center> data recieved from client <center>
    <%
    String s= request.getParameter("t1");
    String a= request.getParameter("t2");
    %>
    username :<%=s%><br>
    address :<%=a%>
    </body>
    </html>
    this is html file
    <html>
    <body>
    <form action="http://localhost:8080/form.jsp">
    enter name <input type="text" name="t1"> <br>
    enter address <textarea name="t2"> </textarea> <br>
    <input type="submit" vaule="login">
    </form>
    </body>
    </html>

    Thanx a lot for ur promt reply.
    we r succful in running simple jsp in tomcat6.0.
    bt one more problem occured as following when we r trying to run jsp file in tomcat.
    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: /main1.jsp(1,1) The value for the useBean class attribute webCounter is invalid.
         org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
         org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
         org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:148)
         org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1200)
         org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1155)
         org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2336)
         org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2386)
         org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2392)
         org.apache.jasper.compiler.Node$Root.accept(Node.java:489)
         org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2336)
         org.apache.jasper.compiler.Generator.generate(Generator.java:3374)
         org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:210)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:306)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    note The full stack trace of the root cause is available in the Apache Tomcat/6.0.13 logs.

  • How to Run JSP in Tomcat Server 3.3.2

    Hi all,
    i have just installed tomcat server 3.3.2 in my system which as windows xp home edition as a operating system and no problem i can able to start the tomcat server.But the problem is that i dont no how to run jsp in tomcat i listed some of my problems below..
    How to put my jsp file in the virtual directory(default and also i want to create ) then tell me how use IE to run the JSP file.
    Thanks in advance..
    With Regards
    Vijay

    Hi all,
    i have just installed tomcat server 4.1 in my
    system which as windows NT 4.0 home edition as a
    operating system and no problem i can able to start
    the tomcat server.But the problem is that i dont no
    how to run jsp in tomcat i listed some of my problems
    below..
    How to put my jsp file in the virtual
    directory(default and also i want to create ) then
    tell me how use IE to run the JSP file.
    Thanks in advance..
    With Regards
    Baliram

  • How to deploy JSPs in Tomcat 5.5

    hello all
    i am Mayuresh Trivedi. i don't know how to Deploy Jsps in Tomcat 5.5. i m using MYSql as Backend. i m trying to use "import" command in Jsp so it shows me error like under :
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: Unable to compile class for JSP
    Generated servlet error:
    Syntax error on token "import", delete this token
    Generated servlet error:
    Syntax error on token "import", delete this token
         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:397)
         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)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.7 logs.
    so , can any body help me please ?

    hi
    first create a arbitrary folder in \webapp folder in tomcat home foder.
    for instance \webapp\myJSP
    second you must create a folder with this name : \WEB-INF under myJSP folder
    then make a web.xml in that
    so write in web.xml this :
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    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/web-app_2_4.xsd"
    version="2.4">
    <description>
    myJSP
    </description>
    <display-name>JSP 2.0 Examples</display-name>

  • Unable to run jsp in tomcat 5.0

    hi ,
    iam unable to run jsps in tomcat 5.0.
    i get an error saying ,unable to compile java compiler
    iam able to compile servlets & execute them.
    i have already set the paths for JAVA_HOME & CATALINA_HOME
    please guide me accordingly
    regards ,
    shailesh

    the same code gets executed in other system in which there is only one jdk.
    the system which iam using has got many jre s due to
    1) netbeans IDE
    2)Weblogic server
    3) jdk 1.4 was previously installed
    4) jdk 1.5 was also installed
    but i have set JAVA_HOME   =jdk1.6
    I doubt the compiler is trying to compile itself or another compiler
    regards ,
    shaileshkumar

  • Runnig JSP on Tomcat

    Hi!
    I run my JSP on Tomcat.
    My problem is with links:
    i create the following code:
    <a href="C:\\inserts.zip">Title2</a>But the browser doesn't download it.
    How can i download the file stright away?
    thanks!

    If You want to enable local file to be downloaded via <a> tag, You have to write a servlet (example), that will read this file and then write it to the response's output stream. In the <a> "href" attribute put the link that will be poiting to the servlet.

Maybe you are looking for

  • How to install Oracle VM Server 2.2.0 as 32-bit mode on a 64-bit machine.

    Gurus, If I am not wrong, the Oracle VM Server 2.2.0 installer for 32-bit and 64-bit are the same file. I have AMD 64 bit machine, when I install Oracle VM Server 2.2.0, it installs as 64-bit. However due to requirement, I want to install Oracle VM S

  • Commercial rounding for capital goods

    Commercial rounding off of all duties All the Duties are rounded up in PO & MIGO with some routing development through ABAP. Now client requirement is that in case of capital goods 1.     If suppose that in Capital Goods Cenvat is Rs. 45.00, in same

  • Why doesnt my skype credit balance appear in app?

    Hi I bought GBP 10 skype credit, which is recorded in my account on website but via android app on my galaxy note 2 it says I have no credit, meaning I cant use the credit as intended?? Any support ideas welcome, thanks.

  • Command TAB in FSRM

    Hello, I have been trying to get the command tab in FSRM to work with no luck. I tried to follow the other suggestion I found online still does not work. Not sure what I'm doing wrong here. I can't get the script to run. I'm testing this on server 20

  • Missing Downloadable Apps After Cloud Subscription

    Only about half the applications advertised as part of Creative Cloud are showing up as downloads. In particular I was hoping to download Premiere and After Effects today. Where are they?