wood burning stoves 2.0*
The moose likes JSP and the fly likes writing jsp  codes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "writing jsp  codes" Watch "writing jsp  codes" New topic
Author

writing jsp codes

oghenekaro EFEKODO
Ranch Hand

Joined: Oct 10, 2005
Posts: 56
pls,am new to jsp and need help on how to start and where to writing jsp codes.i've install the apache tomcat server and don't no where to go from there.pls help!!.
Thanks for your help.
Aravind Prasad
Ranch Hand

Joined: Dec 28, 2005
Posts: 263
Hello oghenekaro EFEKODO,

Writing a jsp code is very simple..
here i can just give u a sample JSP code that can able to print the name ur giving.. and i'll tell u the configuration also.. ok..

---------------------------------------------------------------------------
1) create a folder namee "test" go to any text editor..
2) write the code as given below..
<html>
<head> <title> test</title></head>
<body>
<form name="form1" method="post" action="test.jsp">
<input type ="text" size="20" name="name">
<input type="button" name="submit" value="submit">
</form>
</body>
</html>

3) save the file as index.jsp
4) open new file..
5) write the following code..
<html>
<head> <title> test </title></head>
<body>
<%
String name = request.getParameter("name");
out.println(name);
/*
the String name means the variable to which we are saving the parameter comming from the previous page.. and getParameter("name") the name inside this will represent the value which ur taking from the text box.. u can see the name of the textbox and the argument is same
*/
%>
</body>
</html>
6) save the file as test.jsp
7) create a folder and name it as WEB-INF and create a new file there
8) write the code like this
<web-app>
<display-name>test</display-name>
<description>Test Program</description>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
9) Save this file as web.xml inside WEB-INF
10)create another folder in the root directory called "META-INF" and create new file under that and do the following code there

Manifest-Version: 1.0
Created-By: 1.5.0_06 (Sun Microsystems Inc.)

11) Save the file as MANIFEST.MF
--------------------------------------------------------------------------
now the directory structure will be like this
--test(folder)
-WEB-INF(folder)
.web.xml(file)
-META-INF (folder)
.manifest.mf
.index.jsp(file)
.test.jsp(file

---------------------------------------------------------------------------
then u have to create a war file.. war means web archive
for creating the war.. go to command prompt.
u give the path where u created the folder test
so now for egs ur in the path it will show like this

c:\test> jar -cvf test.war *.*
and press enter..

it will create a war file in the directory.. called test.war
------------------------------------------------------------------------
now. for uploading the file to the Tomcat webserver.. u want the following this,..
check whether the webserver is working fine..
http://localhost:8080/
when u give this.. it will show the home page of tomcat.. the port which the tomcat listens default is 8080..
and u can see a link in the left hand side of the page..
Tomcat manager.. click that link.. there u want to give the username and password.. for loggin in to tomcat manager..

if it is successfully logged in.. the next step is uploading a war file..
u can see "deploy " down in the page.. u have to browse the war file from there and click the deploy..
then ur able to see the program in the list
or give like this

http://localhost:8080/test
u can see the page u did..

check this out..

regards
Aravind
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: writing jsp codes