• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Help me writing an ACTION class in eclipse

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,
i have a question here.
Could some one show me how to work it out.

"Create a JSP called Login.jsp and just to provide two text boxes
a username and password as shown below
Username:
Password:
Cancel Submit


Create an ACTION class. When you SUBMIT the values this action class should
Take those values and output to the console.
"

i have the code for first part.
"<HTML>
<HEAD>
<TITLE>Sending a request</TITLE>
</HEAD>
<BODY>
<FORM ACTION= METHOD="POST">
<BR><BR>
Username: <INPUT TYPE="TEXT" NAME="Username">
Password:<INPUT TYPE="TEXT" NAME="Password" >
<INPUT TYPE="SUBMIT" VALUE="Submit">
<INPUT TYPE="RESET" VALUE="Cancel">
</FORM>
</BODY>
</HTML>
"

Action is empty here coz i dont have any cgi.
Thank You.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please be sure to take the time to compose descriptiv e subjects for your posts; read this for more information.

A title such as "help me" is not helpful. What would happen if all posts had such a title?

Please go back and change your post to add a more meaningful subject by clicking the button on your post.

Also, please use real words when posting to the forums. Abbreviations such as "coz" in place of "because" only serve to make your posts more difficult to read and less likely to generate useful responses.

Please read this for more information.

thanks,
bear
JavaRanch sheriff

 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Action class" sounds like a Struts term. Is this homework for a class on Struts?
 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

sagar podilapu wrote:

Create an ACTION class. When you SUBMIT the values this action class should
Take those values and output to the console.
[/b]"



Well, you need something in the action field (I'd suggest another jsp) that this form is
directed to and it in turn prints out the parameters, or maybe I'm not understanding
your question?

sagar podilapu wrote:
i have the code for first part.
"<HTML>
<HEAD>
<TITLE>Sending a request</TITLE>
</HEAD>
<BODY>
<FORM ACTION= METHOD="POST">
<BR><BR>
Username: <INPUT TYPE="TEXT" NAME="Username">
Password:<INPUT TYPE="TEXT" NAME="Password" >
<INPUT TYPE="SUBMIT" VALUE="Submit">
<INPUT TYPE="RESET" VALUE="Cancel">
</FORM>
</BODY>
</HTML>
"

Action is empty here coz i dont have any cgi.
Thank You.



er, you don't have any cgi? I certainly hope not!
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Karl Krasnowsky wrote:I'd suggest another jsp


I would not. JSPs are units of view, not processing. The target of a form submission should be a servlet.

The mention of CGI confuses me though. Why post about CGI in a forum on JSPs?
 
sagar podilapu
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey thank you guys.
I m sorry for mentioning CGI.
I have written a servlet class named LoginDemo and i pointed my action to this class.
I have written the code but when i m trying to run the program,it gives several errors.
my code is as follows...
"
package javax.servlet.http;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;

public class LoginDemo extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<HTML>");
out.println("<HEAD>");
out.println("<TITLE>Obtaining the Query String</TITLE>");
out.println("</HEAD>");
out.println("<BODY>");
out.println("Query String: " + request.getQueryString() + "<BR>");
out.println("<FORM METHOD=GET>");
out.println("<BR>Username: <INPUT TYPE=TEXT NAME=Username>");
out.println("<BR>Password: <INPUT TYPE=TEXT NAME=Password>");
out.println("<BR><INPUT TYPE=SUBMIT VALUE=Submit>");
out.println("<BR><INPUT TYPE=RESET VALUE=Cancel>");
out.println("</FORM>");
out.println("</BODY>");
out.println("</HTML>");
}
}"


The following are the errors
"
The import javax.servlet.ServletException cannot be resolved
The import javax.servlet.http.HttpServletResponse cannot be resolved
The import javax.servlet.http.HttpServletRequest cannot be resolved
The import javax.servlet.http.HttpServlet cannot be resolved
ServletException cannot be resolved to a type
HttpServletResponse cannot be resolved to a type
HttpServletRequest cannot be resolved to a type
HttpServlet cannot be resolved to a type

"

Please Comment on it.
Thank You.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Still waiting for you to adjust your topic title.
 
sagar podilapu
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i ll change it if i know it..
someone can help me to change this topic name please..
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Those aren't run-time errors, they're compile-time errors.

You need to make sure that the Servlet API classes are on the classpath when you compile the servlet.
 
sagar podilapu
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Bear Bibeault

Thank You.
Could you explain how to check that.
I am new to JAVA and related topics.
I am sorry if i have asked help for an easy task.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How are you trying to compile the servlet?
 
sagar podilapu
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I m using eclipse 3.4.1.
It doesnt allow me to compile as there are some errors.
Thank You.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

sagar podilapu wrote:I m using eclipse 3.4.1.


OK, I've moved this over to the IDEs forum where eclipse issues are dealt with.
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is j2ee.jar or servlet-api.jar in the classpath for the Java project?
 
sagar podilapu
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let me Explain what i have done.

In eclipse 3.4.1,i went into Buildpath>>Configure Buildpath>>Projects>>add.
I couldnt fine my project overthere to add to a classpath.
Thid is the only error i came across when i run my program on tomcat server.
it says
type Status report

message /SagarIVRApp/ACTION.java

description The requested resource (/SagarIVRApp/ACTION.java) is not available.



I will provide my entire program.
Can someone help me
Can someone compile it in eclipse and figure t out please.

My Login.JSP

"
<HTML>
<HEAD>
<TITLE>Login</TITLE>
</HEAD>
<BODY>
<FORM ACTION = "ACTION.java" METHOD="POST">
<BR><BR>
Username: <INPUT TYPE="TEXT" NAME="Username"><BR>
Password:<INPUT TYPE="TEXT" NAME="Password" ><BR>
<INPUT TYPE="SUBMIT" VALUE="Submit">
<INPUT TYPE="RESET" VALUE="Cancel">
</FORM>
</BODY>
</HTML>
"

My ACTION.java
"package Com.kronsys.xxxx;
public class ACTION {
String Username;
String Password;
public void SetUsername(String value)
{
Username=value;
}
public void SetPassword(String value)
{
Password=value;
}
public String GetUsername(){
return Username;
}
public String GetPassword(){
return Password;
}

}
"

This program is to write a JSP to get USERNAME AND PASSWORD and then to write and ACTION class to display the given username and password.
 
There’s no place like 127.0.0.1. But I'll always remember this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic