Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-06-2007, 04:07 PM
Member
 
Join Date: Jul 2007
Posts: 6
Unni is on a distinguished road
Blank result for jsp_servlet in Eclipse
Hello all,

Greetings!!!

I am new to this forum and also to Eclipse..

Have created index.jsp under WebContent in Eclipse. Having firstname and surname text boxes with submit button. Contents look like :

Code:
<form action="GreetingServlet" method="POST"> First Name: <input type="text" name="firstName" size="20"><br> Surname: <input type="text" name="surname" size="20"> <br><br> <input type="submit" value="Submit">
and created GreetingServlet by right clicking ProjectName(HelloServlets) -> New -> Projects -> Servlet
Contents look like:

Code:
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); String firstName = request.getParameter("firstName").toString(); String surname = request.getParameter("surname").toString(); }
The problem is that, variables out,firstName,surname are underlined with yellow line in Eclipse's default browser . and when i keep the cursor on that variables then it displays warning message like "The local variable is never read".

SO i guess no contact between jsp and servlet files.. but when i submit the page is directing to http://localhost:8080/HelloServlets/GreetingServlet

but its blank .. Pls Help to execute this program correctly in Eclipse

Thanks in advance

Regards
Unni

Last edited by JavaBean : 07-06-2007 at 08:21 PM. Reason: Codes should be put inside [code] tags!
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-08-2007, 11:34 PM
Senior Member
 
Join Date: Jun 2007
Posts: 114
Albert is on a distinguished road
The warning appears because you don't write the lines to print the first name and surname.

Code:
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println("<title>Example</title>" + "<body bgcolor=FFFFFF>"); out.println("<h2>Button Clicked</h2>"); String firstName = request.getParameter("firstName").toString(); String surname = request.getParameter("surname").toString(); if(firstName != null){ out.println(firstName); } else { out.println("No text entered."); } if(surname != null){ out.println(firstName); } else { out.println("No text entered."); } }
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-12-2007, 05:30 AM
Member
 
Join Date: Jul 2007
Posts: 6
Unni is on a distinguished road
Blank result for jsp servlet in Eclipse
Thank you so much Albert

I could run and got the answer.. Thanks for ur immediate reply.. I couldnt reply early since i went to my native..

and am expecting more from u.. nice to meet u..

Once again Thanks!!

Regards
Juni
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how can we remove blank lines from a .txt Camden New To Java 1 03-12-2008 07:02 AM
Iterating through result set in JSTL Java Tip Java Tips 0 01-15-2008 04:13 PM
Iterating through result set in JSTL Java Tip Java Tips 0 01-14-2008 10:31 AM
Print a blank space susan New To Java 2 07-30-2007 02:58 PM
getting a random result gradon New To Java 2 07-19-2007 04:54 PM


All times are GMT +3. The time now is 08:56 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org