Hi I am new to Jsp,Please help me.
This is my Jsp Program:
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class login extends HttpServlet {
private String target = "/welcome.jsp";
private String getUser(String username, String password) {
// Just return a static name
// If this was reality, we would perform a SQL lookup
return "Frodo";
public void init(ServletConfig config)
throws ServletException {
super.init(config);
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
// If it is a get request forward to doPost()
doPost(request, response);
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
// Get the username from the request
String username = request.getParameter("username");
// Get the password from the request
String password = request.getParameter("password");
String user = getUser(username, password);
// Add the fake user to the request
request.setAttribute("USER", user);
// Forward the request to the target named
ServletContext context = getServletContext();
RequestDispatcher dispatcher =
context.getRequestDispatcher(target);
dispatcher.forward(request, response);
public void destroy() {
when i compile this i got this error:
cannot find symbol:
setAttribute()
request.setAttribute("USER",user);
cannot find symbol:
class RequestDispatcher
RequestDispatcher dispatcher =
context.getRequestDispatcher(target);
Hey no need of that . you can use request scoped attributes too.
and remember this is not JSP. it's a SERVLET
your code is completely correct. there are no errors in it. i am pasting your code. just check it.
It's working properly. no compile time errors occured.
import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class login extends HttpServlet {
private String target = "/welcome.jsp";
private String getUser(String username, String password) {
// Just return a static name
// If this was reality, we would perform a SQL lookup
return "Frodo";
public void init(ServletConfig config)
throws ServletException {
super.init(config);
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
// If it is a get request forward to doPost()
doPost(request, response);
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
// Get the username from the request
String username = request.getParameter("username");
// Get the password from the request
String password = request.getParameter("password");
String user = getUser(username, password);
// Add the fake user to the request
request.setAttribute("USER", user);
// Forward the request to the target named
ServletContext context = getServletContext();
RequestDispatcher dispatcher =
context.getRequestDispatcher(target);
dispatcher.forward(request, response);
public void destroy() {
}Let me know where you are getting issues exactly.
Diablo
Similar Messages
-
Is there a way to run a 2005 PreSonus Firebox(with the firewire) to a mid-2011 iMac 0SX 10.7.2? It says its no longer supporting Power PC? Anything I can do without spending more money on new equipment or a new computer? Please help me.
Nevermind, I got it working.
I ended up extracting the new vob within MPEG Streamclip, which gave me an m2v and an aiff audio. I multiplexed those two back together in FFMpegX which gave me a complete VIDEO_TS folder with BUP and IFO files I needed. -
Hello Guys.
I had problems in the Computer before and changed my HD. I saved in my all files documents in (Time Capsule). How can I put all my files, pictures documents on my new HD?
Please Help.
Thank You
Julio SkovHey
Thank you very much for replay.
Would you explain to me how can I do?
I don't really understand these processes.
Thak you very much
Julio -
I purchased an audiobook in Nov 2012 using iPhone 4S and then upgraded to iPhone 5 in Dec. Now I am not seeing the audio book in purchase history in iTunes. This means I am not able to get the book in my new iPhone. Please help.
Audiobooks are currently a one-time only download from the store. If you don't have it on your computer (audiobooks go into the Books part of your iTunes library) nor on a backup, then if it's still in the store you can try contacting iTunes support and see if they will grant you a re-download : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page
-
I have no trouble viewing apps in the iTunes Store on my iPad. However, every time I try to install a new app, I get an error message after a while - cannot connect to iTunes Store. This issues cropped up two days ago on my new iPad. Please help...
JUst experienced the exact same problem after changing password.Getting same message. Hope someone has an answer for this.
-
Hi can anyone help me. I have a apple macbook laptop OSX 10.5.8 . When i push print, it shows my printer but says cannot communicate with printer. (epson stylus nx125). Do I need new drivers? Please help . regards Cindy
Welcome to Apple Support Communities. We're users here and do not speak for "Apple Inc."
Some basic printer troubleshooting steps before worrying about a printer driver:
1. Have you tried turning the printer off and back on?
2A. Is the printer attached with a cable?
If yes, have you tried unplugging and re-plugging both ends of the printer cable?
If that does not help, can you test the printer with another cable?
2B. If your printer is not connected to the computer with a cable, have you tried restarting your printer (assuming wireless connection)?
Have you tried restarting your wireless router?
3. Have you tried restarting your MacBook? (Be sure to save your work first.)
4. Does the printer have ink? (Doesn't usually generate a 'communications error' though)
5. Have you updated OS X or the program you're trying to print from recently? -
my osx version is 10.8.2. i was buying the facetime app for my mac. i got this error -"FaceTime can’t be installed on “Macintosh HD” because the version of OS X is too new." so please help me out of this funny situation.
https://www.apple.com/support/mac-apps/facetime/
-
NEED NEW CARD! Please help
Alright, well my dumbass roommate decided to plug in his super nintendo to my TV@nywhere card. To make a long story short, he messed something up. The computer wouldnt boot. It would get to the windows screen and freeze. I formatted, problem was no more, untill I installed the VGA drivers.
So now I cant do anythign with my screen, if I install the drivers, it wont boot.
Now I plan on just getting a new VGA card. Was looking at some nVidia products, but I am uncertain what to get. I want to spend $50 or less (eBay).
I have the MSI 651 MEGA PC. It says it has a APG 4x x1 slot on board, so I was just wondering what suggestions you guys had for a new card. Please help out if possible, thanks!Try the second hand ATI 9600XT.
-
I want to transfer my Adobe CS3 licence to my new Laptop.
Please help me for Deactivate Adobe CS3 licence from old LaptopHi sanket chalke,
I'm not sure what Adobe product you need help with, but you might want to start with this document, which has deactivation information: Activation & Deactivation Help
Please let us know how it goes.
Best,
Sara -
i have less than 5 authorised computers. yet cannot authorise my new iMAC27. Please help..
Hello Morfaly,
Thanks for the question. The following article may provide a solution to your issue:
iTunes: Missing folder or incorrect permissions may prevent authorization
http://support.apple.com/kb/TS1277
Thanks,
Matt M. -
I have been trying to get the full version of lightroom after using a trial version but it says something about "GB" ? And i need to log into different account or set up a new one? Please help?
I would love to give you more information but i cannot access that page again? i can add Lightroom to my cart but when i go into my cart it says there is nothing in there? I have a red bubble above "my cart" with a number 4 in it to show there is something there but there is not? It just wont let me buy anything?
-
evidence of a freakin' rootkit (of sorts) haunting my remaining neurons for the last year @ all my android devices (including this new tablet).
PLEASE HELP ME
Jose Carlos Amaral Morgado
Tomar, Portugal
'''...personally identifying information removed'''Sorry Morgado. This is a Firefox for Android support forum. Not a general purpose. Android forum. Please ask in an Android OS forum.
Locking this thread.
Cheers!
...Roland -
I have lost my new iPhone. Please help. I have the IMEI no and all the details that comes at the back of the box.
Having the imei won't help you find your phone.
If you setup and enabled find my phone prior to losing it then go to icloud.com
If you didn't set it up - then there nothing you can do.
Call your carrier and let them know, change all your passwords. -
I am new to mac please help me basic tips an trick to use mac
i am new to mac please help me basic tips an trick to use mac its very frustrating for any thing i have to call apple help line
any acesserious to macbook air 13 like any silicon case or carry case or some acesserious
i have delete contains of master folder of phothos still i can see phothos in my mac so how can i delete itApple has a site for new users. Use it. Also, David Pogue is an excellent tech writer who has penned a series called the Missing Manual. I assume you've come to the Mac from the Windows world and he's written one especially for switchers. I've linked to the version for Mavericks (10.9) but if you have an earlier version of the Mac OS he's written a similar book for them as well.
-
my i phone 4 cannot charge continously. it will charge then after few seconds its off then charge again. I cannot open it because it runs out of battery do i need a new battery?please help.
You could always check to make sure itunes is updated to 10.7 but im sure gdgmacdude is
right.
thanks
gdgmacdude
Hey dude
are there anymore hardware failure errors u know of
im kinda a novice apple man and could use all the help i can get
capp
Maybe you are looking for
-
PL/SQL vs Pro*C / Cobol
Can any one tell me whether PL/SQL can totally replace Pro*C / Cobol? I remember there is a PL/SQL package called UTL_FILE, which enable user to do File I/O. However, I wonder whether it really excel the File I/O capability of the conventional Cobol
-
Consuming web services provided 3rd
Hello experts, I have a scenario SAP -> XI -> 3rd party WS (with multiple actions) The 3rd party WS contains several actions for manipulating a Business Object. I would like to define one Inbound Service Interface with several Operations for consumin
-
Trying to find Java release 1.6.0.1_45, any ideas
Trying to find Java release 1.6.0.1_45, any ideas
-
11g rel 2 RAC on RHEL5.2
TASK: need to install 11g rel 2 RAC on a two node RHEL (2.6.18-128.el5 #1 SMP Wed Dec 17 11:41:38 EST 2008 x86_64 x86_64 x86_64 GNU/Linux). What are the RPM's needed for the cluster installation? Regards,Lily.
-
Can't change the media type in iTunes
I just recently bought my first MBP and I have been busy transferring all my files from my Vaio to my MBP. I convert all my dvds to digital format and keep them on an external HDD (LaCie 1TB HDD) and was adding them to my iTunes on my MBP. I came acr