Hi Sourabh,

Again, thanks for responding to my message.


I am a beginner with Servlets and I only had ONE (introduction) Java class,
and no formal HTML training. I apologize if I'm asking very simple
questions.

In your reply below to my earlier question, I have seen examples on how to
design HTML web pages but I'm not sure how to design them using indexes,
parameters, etc. for servlets.

What I want to accomplish with this Servlet is to create messages and allow
my servlet to be passed an URL (query string), with the appropriate message
index, and display a different page page for each message based on the
index. If there is no message for an index, an error message should be
displayed.


-----Original Message-----
From: Sourabh Kulkarni [mailto:[EMAIL PROTECTED]]
Sent: Monday, February 18, 2002 08:39
To: [EMAIL PROTECTED]
Subject: Re: Servlet Question


Hi Melvin,
    Have the request as
http://localhost:8080/myservlets/MessageServlet?index=3
(If the page index is 3).

    In servlet, use
    int index = Integer.parseInt(request.getParameter("index"));
    String message = (String)list.get(index);

-sourabh


----- Original Message -----
From: Melvin Grady <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, February 18, 2002 5:24 PM
Subject: Servlet Question


> In my doGet method of my servlet I have created a List of messages. The
code
> follows:
>
>    file://Declare and Initialize String array with messages
>    private String values[] = { "Message1", "Message2",
>                                "Message3","Message4", "Message5" };
>
>   private List list; file://Declares a List reference called list
>
>    // initialize List and set value at first location [Index 0]
>    public UsingAsList()
>    {
>       list = Arrays.asList( values );  // Static method to get a
fixed-size
> List
>       list.set( 0, "Message1" );  // change a value
>    }
>
> Question:  How do I display each message on a different page using a index
> parameter passed to the servlet?
>
> My servelet name is MessageServlet and my URL to my Tomcat 4.0 Web Server
> is:
> http://localhost:8080/myservlets/MessageServlet
>
>
>
>
>
> Melvin
> [EMAIL PROTECTED]
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to