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%>
address :<%=a%>
</body>
</html>
this is html file
<html>
<body>
<form action="http://localhost:8080/form.jsp">
enter name <input type="text" name="t1">
enter address <textarea name="t2"> </textarea>
<input type="submit" vaule="login">
</form>
</body>
</html>
Sathish,
Follow the following steps to compile your JSP files.
1) save all your JSP files in a folder by name "test". Place "test" in "webapps" folder in Tomcat server.
2)Start tomcat server
3)open IE and type following in the URL:
http://localhost:8080/yourfoldername/filename.jsp
example:
http://localhost:8080/test/input.html
If all your settings are correct, you can find your html page on IE.
4) Give inputs in your html file. Press submit button.
Note:
<form action="your jsp file name">
for example:
<form action="nextpage.jsp" method="post">
hope this helps
Regards,
Ashvini
thanks ashvinia lot i got worked out
hi, i m vipul
i want to know step to run jsp from starting at creation of jsp file means what setting we have to made in our system lke setting the path ,creating the folder in webapps or every thing until run the jsp file on the internet explorer.
Thanks & Regards
vipul patel
hi Vipul,please, visit the following link : http://www.coreservlets.com/Apache-Tomcat-Tutorial/I think this will satisfy all of your queries.Thanks and Regards,Amol Chaudhari
as u step given by u i m not able to understand.
i will give you my problem step by step so u can understand easily and give me the solution of that.
1> i have created a jsp file ok now where i have to store that file.
2> before compile i have to set any path for jdk and tomcat or any think else?
3> i want to know how to compile jsp file on jdk (is it neccesity of jdk).
please give me the solution as possible as fast because i have to learn jsp .
if u not understand my problem than contact me on my chat email id on chat vbpatel_unjha@yahoo.com
Thanks & Regards
Vipul
you have to set path for jdk
You can do that by setting env. varible in system properties/ advance/ enviornment variable
Go to System variable than click new
Variable name = Path
variable value = <JDK_HOME>/bin;
and I think you dont have to compile any jsp file just put that file directly in <tomcat_home>\webapps\ROOT folder.
then start tomcat and open IE and type following in the URL:
http://localhost:8080/filename.jsp
U must set the classpath
Assume that your the jdk floder is d:\sun\jdk\ and your os is windows
set the JAVA_HOME=d:\sun\jdk\
set the classpath=.;%JAVA_HOME%\lib;
add the path=%JAVA_HOME%\bin;
then you can compile your .java source file;
if your file's name is test.java
enter javac test.java
At the time of compling JSP files in "http:/localhost/test/hello.jsp"
i got this error "http:/status 404" request resource is not avaliable.
Is there is any requirement to compiled JSP files before running in http loca host test\hello.jsp and if YES then how to complie
i hv already installed JDK1.6 in C:/Java and Tomcat 6.0 in D:/Tomcat also i have set all the environmental variables and Class Path as
"JAVA_HOME C:\JAVA
CATALINA_HOME D:\TOMCAT
PATH VARIABLES:
C:\Java\bin
Message was edited by:
madhu@
first step is to set jdk path
java path(java istallation bin directory)
eg:
C:\j2sdk1.4.1_07\bin;
use the following step in windows2000,xp to set jdk path
1.Right click my computer icon in the desktop
2.select properties
3.select advanced tab
4.click environment variables
5.Select new from "user variables for user"
6.enter variable name=PATH
7.variable value=C:\j2sdk1.4.1_07\bin(your path)
8.click ok.
it will set java path permenently in your system
Run JSP file in tomcat
1.Create a simple JSP page
2.creare a folder under webapp directory in tomcat installation path
eg:C:\Tomcat\webapps\hello it may vary
3.put our jsp file in that folder.
4.start tomcat server
5.open a web browser
6 type the url as follows
http://localhost:8080/foldername/filename
foldername="folder created under webapp directory"
filename=created JSP file.
Please try this
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.