Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
|
JSP Basics Beginning-level questions on JSP. More advanced coders should post to Pro JSP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the JSP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 12th, 2004, 07:31 AM
Registered User
 
Join Date: Mar 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default java code not working in JSP

Hi,

I am using weblogic server and written the below JSP code
<%@ page language="java" %>
<html>
<head>
<title> JSP sample</title>

</head>
<body>
<p>
    <% int numTimes = Integer.parseInt(request.getParameter("numtimes")) ;
    out.write("Numoftimes :" + numTimes )
    for (int i = 0; i < numTimes; i++ )
    {
    %>
    Hello World!! <BR>
    <%
    }
    %>

</p>
<%@ include file="PageFooter.html" %>
</body>
</html>


And the corresponding HTML code from where I am calling the above JSP code is

<HTML>
<HEAD>
<TITLE>
Simple JSP Examples
</TITLE>
</HEAD>
<BODY>
<P> How many times ?</P>

<FORM METHOD="GET" ACTION= "SimpleJSP.jsp">

<INPUT TYPE="TEXT" SIZE="2" NAME="numtimes">
<INPUT TYPE= "SUBMIT">

</FORM>


</BODY>
</HTML>

However, whatever the option that I enter for the numtimes it is print Hello World only once.

I am sure that the java script code is not executing

<% int numTimes = Integer.parseInt(request.getParameter("numtimes")) ;
    out.write("Numoftimes :" + numTimes )
    for (int i = 0; i < numTimes; i++ )
    {
    %>
    Hello World!! <BR>
    <%

You can find the above example in professional Java book by Wrox publishers...

Any body who know the solution please post it to me....

Regards,

Srinivas.
 
Old March 16th, 2004, 12:52 AM
Authorized User
 
Join Date: Feb 2004
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to cash
Default

You could look up the value of "request.getParameter("numtimes")".I try the code like this:

int numTimes = Integer.parseInt("5");

and it works well!

out.write("Numoftimes :" + numTimes ) ';' expected.

Regards








Similar Threads
Thread Thread Starter Forum Replies Last Post
JSP pages not working after reinstalling Tomcat sagar.singh Apache Tomcat 3 October 24th, 2007 01:28 AM
Ajax + Java (Jsp) nigam.anand BOOK: Professional Ajax ISBN: 978-0-471-77778-6 6 January 18th, 2007 12:19 PM
Java Code - Wrox - Beginning JAVA - Ivor Horton ponguru Java Databases 3 May 18th, 2006 12:30 PM
java and jsp harshika Apache Tomcat 1 August 6th, 2005 05:15 PM
jsp working but servlet not....... rai Apache Tomcat 0 June 23rd, 2005 12:37 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.