Accesing a html parameter from servlet is not producing in a new file

Hi,...
I have passed two values from html and accessed thru a servlet file.
In servlet, parameters are verified and result must passed to a new jsp file.
Wen i run the file i can view only a blank page.I think the problem will be in servlet mapping.
verify my coding and give me a result.
I wer using net bean 6 with glassfish v2 server.
public class Logverifier extends HttpServlet {
* Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
* @param response servlet response
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
try {
/* TODO output your page here
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet Logverifier</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Servlet Logverifier at " + request.getContextPath () + "</h1>");
out.println("</body>");
out.println("</html>");
ServletConfig config=getServletConfig();
String user=config.getInitParameter("user");
String pass=config.getInitParameter("pass");
ServletContext context=getServletContext();
RequestDispatcher reqdis=context.getRequestDispatcher("menu.jsp");
RequestDispatcher reqdis1=context.getRequestDispatcher("login.jsp");
if((user.equals(request.getParameter("user")))&&(pass.equals(request.getParameter("pass"))))
reqdis.forward(request, response);
else
reqdis1.forward(request, response);
} finally {
out.close();
<servlet>
<servlet-name>Logverifier</servlet-name>
<servlet-class>com.Logverifier</servlet-class>
<init-param>
<description>          </description>
<param-name>user</param-name>
<param-value>admin</param-value>
</init-param>
<init-param>
<param-name>pass</param-name>
<param-value>media</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Logverifier</servlet-name>
<url-pattern>/com/Logverifier</url-pattern>
</servlet-mapping>
</servlet>
regards,
satheesh

Hi,...
I have passed two values from html and accessed thru a servlet file.
In servlet, parameters are verified and result must passed to a new jsp file.
Wen i run the file i can view only a blank page.I think the problem will be in servlet mapping.
verify my coding and give me a result.
I wer using net bean 6 with glassfish v2 server.
public class Logverifier extends HttpServlet {
* Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
* @param response servlet response
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
try {
/* TODO output your page here
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet Logverifier</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Servlet Logverifier at " + request.getContextPath () + "</h1>");
out.println("</body>");
out.println("</html>");
ServletConfig config=getServletConfig();
String user=config.getInitParameter("user");
String pass=config.getInitParameter("pass");
ServletContext context=getServletContext();
RequestDispatcher reqdis=context.getRequestDispatcher("menu.jsp");
RequestDispatcher reqdis1=context.getRequestDispatcher("login.jsp");
if((user.equals(request.getParameter("user")))&&(pass.equals(request.getParameter("pass"))))
reqdis.forward(request, response);
else
reqdis1.forward(request, response);
} finally {
out.close();
<servlet>
<servlet-name>Logverifier</servlet-name>
<servlet-class>com.Logverifier</servlet-class>
<init-param>
<description>          </description>
<param-name>user</param-name>
<param-value>admin</param-value>
</init-param>
<init-param>
<param-name>pass</param-name>
<param-value>media</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Logverifier</servlet-name>
<url-pattern>/com/Logverifier</url-pattern>
</servlet-mapping>
</servlet>
regards,
satheesh

Similar Messages

  • How can I display the HTML page from servlet which is called by an applet

    How can I display the HTML page from servlet which is called by an
    applet using the doPost method. If I print the response i can able to see the html document. How I can display it in the browser.
    I am calling my struts action class from the applet. I want to show the response in the same browser.
    Code samples will be appreciated.

    hi
    I got one way for this .
    call a javascript in showDocument() to submit the form

  • I can not delete or copy new files to my Iomega external hard drive

    Hi,
    I can not delete or copy new files to my Iomega external hard drive. Opening hard drive folder I can see that I can not overwrite it. I have heard that I need to install some program for the external hard drive to operate properly in Mac.
    Please help what to install or there is some other option.
    Thnx

    I'm not the expert on this since I have never done it. It sounds like you may need a data rescue program like Data Rescue III. I believe you can download a demo and see if you can see the files. If you can, then you can buy the program and retrieve the files. I don't know if Disk Utility can restore them--I think they have to be visible but this is not something I have ever had to do.
    In the meantime, don't do anything with the drive--you don't want to overwrite any files. Hopefully all or most of the files are still there and you will be able to retrieve them. The less the drive is used, the better your chances are of retrieving the data.
    Forgive me for not realizing that there were files on the drive that you wanted to save. Upon re-reading your question, I now see that there were. I should have known to warn you, and my bad that I didn't.
    Good luck!

  • How to call a html page from servlet

    i want to link a servlet to a html page, if i use requestdispatcher, it says XXX.html is not available, can anybody help

    Can you be more specific about what you're trying to do? Can't read your mind =). But if you mean you want to just have an static HTML page such as a header read by the servlet you can you the requestdispatcher include().
    Create a servlet to generate a page, and then map it as /getPage in the web.xml file. Then you can use:
    // header
    RequestDispatcher rd = ...getRequestDispatcher("/getPage");
    rs.include(req, res);
    // the rest of the servlet output
    // and you can do another one for the footer down here
    rd = ...getRequestDispatcher("/getPageFooter");
    rs.include(req, res);
    and it'll output the HTML in the servlet.
    Hope this helps

  • Bought 64gb playbook from amazon and not sure if its new or refurbishe​d.

    Bought 64gb playbook from amazon for my daughter and not sure if its new or refurbished.  Tablet has small fine scratches on the back, hair stuck in the casing, no screen protector, brown adaptor box has had label of some kind removed, adapter inside is loosely bound.   Amazon supplier advises me to return but also that it isn't supplied with a screen protector or cover and adapter is new and packaged in a brown box.  Not sure whether to accept a replacement or just get a refund.  A bit concerned that this is a refurbished item being supplied as new.
    Solved!
    Go to Solution.

    Definately sounds like it's not a new item, this isn't how they come packaged.
    If you've been helped click on , if you've been saved buy the app.
    Developer of stokLocker, Sympatico and Super Sentences.

  • HT201269 I used Article: HT2109 to transfer everything from my iPod touch 3g, iOS 5.1.1, to my iPod touch 5g, iOS 6.1.3. Why did data from apps did NOT move to the new device? Games are starting over rather than picking up where they were on the old devic

    I used Article: HT2109 to transfer everything from my iPod touch 3g, iOS 5.1.1, to my iPod touch 5g, iOS 6.1.3. Why did data from apps NOT move to the new device? Games are starting over rather than picking up where they were on the old device?

    - If you restored the 5G frmm the iTunes backup of the 3G were th app in the iTunes library of the computer you used? They have to be.
    - If yes then try again. When I first restored my iPad 4 from the iTunes backup of my iPad 1 app data did not transfer. I tried again and it did.

  • Servlet can not find classes in ear file, only in system classpath.

    Hi,
              My servlet "DataServlet" is included in ear/war file.
              When I try to reach it:
              http://www.mysite.com/DataServlet
              Servlet starts execute doPost() and throw Exception ClassNotFound.
              All classes inculuded in ear files and all jsp working fine.
              It works like standalone servlet and not as part of web application.
              Maybe, there is problem in context root?
              web.xml configuration:
              <servlet-mapping>
              <servlet-name>
              DataServlet
              </servlet-name>
              <url-pattern>
              /DataServlet
              </url-pattern>
              </servlet-mapping>
              application.xml configuration:
              <web>
              <web-uri>data.war</web-uri>
              <context-root>data</context-root>
              </web>
              Thanks,
              Oleg.

    Is the ClassNotFoundException on the DataServlet class, or a class the DataServlet class is trying to use?
              Did you try <http://www.mysite.com/data/DataServlet>?
              I would recommend you always define your classes in packages, as opposed to the default package, which you appear to be using. You'll run into problems down the line if you use the default package.

  • File Name not set when creating new file in EP 6.0 SPS20

    Hi,
    We recently upgraded from EP6 SP15 to SP20. Now when I create a new file or folder in a KM folder, the name that I give for the resource is not taken into account. The display name  of the newly created resource will be <b>New Text</b> or <b>New HTML Document</b> or <b>New Folder</b>, etc. Even if I open the Properties and change it there, it is not getting reflected. But if I select Rename from the Context menu and give a new name, it gets set. What could be the problem?
    Thanks in advance
    Regards
    Ranjith

    Hi,
    It was an issue with the customized PropertiesControl class.
    Regards
    Ranjith

  • Illustrator CC(2014) does not open or create new file in Window 8.1 Pro

    My illustrator can launch but once I tried to create a new file it would freeze and will not respond anymore.
    I also tried to open existing illustrator files it just create a blank white illustrator window and does not respond afterwards as well.
    I tried to reinstall the illustrator for times to fix to issue but it doesnt work.
    All the other applications (photoshop/indesign...) work perfectly, but obviously there is a bug in illustrator...
    Have any other people experienced similar issue and know how to fix it??

    Did you uninstall then used the Cleaner tool before reinstalling?
    Is a printer connected? Is the driver up to date? Printer turned on?
    Do you have any third party plugins installed?
    A graphic tablet?
    Any other hardware?
    Font management? Which one?
    Have you already tried setting up a new user account (Admin) and launching from that one?

  • When Photoshop CS6 is invoked from PSE 11 Organizer why is a new file created with _edited-1 appende

    I just converted a large PSE 10 catalog to work with a downloaded trial version of PSE 11.  When I brought up the Organizer and clicked on the Editor button I selected Photoshop CS 6.  At that point the Organizer created an image stack with a new file on the top of the stack that had a file name that was the original file name with "_edited-1" appended to the end of it.  Is there any way to avoid this?  For me it is going to create a tedious step to delete the original file and rename the new file after editing.  For probably 98% of my editing I will use only the Adobe Camera Raw editor on my imported raw files (Nikon's .nef).  ACR puts the editing data in a sidecar .xmp file so there's no need to protect the original file from be mistakenly replaced by an edited version.

    That's not a new behaviour : in old versions choosing the external editor did create a copy in a version set.
    I don't have CS6, so I can't be specific, but I wonder why you should open CS6 if most of your images can be edited in ACR. For them, you only need to click 'Done' and that saves the edits in the xmp sidecar file. I guess most of the remaining files could be processed in the PSE11 editor and saved in any image format (jpeg, tiff, psd...). Only a minority would have to be processed in CS6***, and in that case, creating a new copy in a version set seems quite reasonable.
    Edit:
    *** in CS6 or the full ACR version of CS6. In my case, it's very rare that I need the other tabs in ACR.

  • Passing parameter from Servlet to javascript in JSP. Very Urgent - 5 jukes!

    Well my servlet will retrieve questions from database.
    Then the player will answer the question in the JSP and submit the answer to the servlet to process.
    Each time an answer is submitted, or a "Next Question" button is clicked, the countdown time will restart.
    And will reload the page with a new question.
    So how can i do that?
    This is my servlet, JSP, javascript
    =====================================================================
    * Interacts with the player depending on his types of selection and output them
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.util.*;
    public class GameQuestionServlet extends HttpServlet
         String sSQL = null;
         String sCategory = null;
         String paramName = null;
         User userObject = null;
         Questions gameQsObj = new Questions();
         HttpSession session;
         int cnt = -1;
         int score = 0;
         boolean connected = false;
         public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
              session = request.getSession(false);
              //System.out.println("Testing Score:" + score);
              if(connected == true)
                   Questions object = (Questions)gameQsObj.getQsList().elementAt(cnt);
                   System.out.println("\n" + object.sAns1);
                   System.out.println(object.sAns2);
                   System.out.println(object.sAns3 + "\n");
                   Enumeration enum = request.getParameterNames();
                   while(enum.hasMoreElements())
                        paramName = (String)enum.nextElement();
                        if(paramName.equals("mcq"))
                             System.out.println(request.getParameter("mcq"));
                             score = Integer.parseInt(userObject.score.trim());
                             System.out.println("Player old score: " + score);
                             //Check to see if the selected answer matches the correct answer
                             if((object.sCorrect).equals(request.getParameter("mcq")))
                                  score = score + 10;
                             else
                                  if((object.sCorrect).equals(request.getParameter("mcq")))
                                       score = score + 10;     
                                  else
                                       if((object.sCorrect).equals(request.getParameter("mcq")))
                                            score = score + 10;     
                                       else
                                            score = score - 10;     
              System.out.println("Player current score: " + score);
              else     //will only go into this once
                   userObject = (User)session.getAttribute("user");
                   System.out.println("\n"+userObject.nric);
                   System.out.println(userObject.name);
                   System.out.println(userObject.password);
                   System.out.println(userObject.email);
                   System.out.println(userObject.score+"\n");
                   //depending on user selection
                   sCategory = request.getParameter("qsCategory");
                   sSQL = "SELECT * FROM " + sCategory;
                   gameQsObj.getQuestions(sSQL, sCategory);
                   score = Integer.parseInt(userObject.score);
                   connected = true;
              System.out.println("Connected:" + connected);
              System.out.println("Before:" + userObject.score);
              cnt = cnt + 1; //increment to retrieve next question
              userObject.score = Integer.toString(score);     
              System.out.println("After:" + userObject.score);
              if(cnt < 3) //setting for the number of questions per game.
                   //request.setAttribute("qsCnt", cnt); //count of the question number
                   request.setAttribute("aQs", gameQsObj.getQsList().elementAt(cnt));
                   System.out.println(request.getAttribute("aQs"));
                   System.out.println("This is question number: "+ cnt);
                   getServletConfig().getServletContext().getRequestDispatcher("/JSP/PlayGame.jsp").forward(request, response);
              else
                   //forward to the result page     
         public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
              doPost(request, response);
    <%@ page import="Questions" %>
    <HTML>
         <HEAD>
              <TITLE>Play Game</TITLE>
              <SCRIPT LANGUAGE="JavaScript">
                   var refreshinterval=10
                   var displaycountdown="yes"
                   var starttime
                   var nowtime
                   var reloadseconds=0
                   var secondssinceloaded=0
                   function starttime() {
                        starttime=new Date()
                        starttime=starttime.getTime()
                        countdown()
                   function countdown() {
                        nowtime= new Date()
                        nowtime=nowtime.getTime()
                        secondssinceloaded=(nowtime-starttime)/1000
                        reloadseconds=Math.round(refreshinterval-secondssinceloaded)
                        if (refreshinterval>=secondssinceloaded) {
                   var timer=setTimeout("countdown()",1000)
                             if (displaycountdown=="yes") {
                                  window.status="You have "+reloadseconds+ " second before timeout"
                   else {
                        hide();
                   clearTimeout(timer)
                             //window.location.reload(true)
                   function hide() {
                        //hidelayer
                        if(gameLayers.style.visibility == "visible"){
                             gameLayers.style.visibility = "hidden"
                             oops.style.visibility = "show"
                   window.onload=starttime
              </SCRIPT>
         </HEAD>
         <BODY>
              <FORM METHOD="post" ACTION="http://localhost:8080/Java_Assignment2/servlet/GameQuestionServlet">
                   <DIV ID="oops" STYLE="position:absolute; left:300px; top:30px; width:120px; height:150px; z-index:2; visibility:hidden">
                        Oops! 30 seconds time up!!! <BR><BR>
                        <INPUT TYPE="submit" VALUE="Next Question">
                        <INPUT TYPE="hidden" NAME="nextQs" VALUE="Next Question">
                   </DIV>
                   <DIV ID="gameLayers" STYLE="position:absolute; left:300px; top:30px; width:120px; height:150px; z-index:3; visibility:show">
                   <TABLE BORDER="0">
                        <TR>
                             <TH><BIG>Questions:</BIG></TH>
                        </TR>
    <%
                        Questions aQsObj = (Questions)request.getAttribute("aQs");
                        String aQsBody = aQsObj.sQs;
                        String aQsAns1 = aQsObj.sAns1;
                        String aQsAns2 = aQsObj.sAns2;
                        String aQsAns3 = aQsObj.sAns3;
    %>
                        <TR>
                             <TD><B><%= aQsBody%></B></TD>
                        </TR>
                        <TR>
                             <TD>
                                  <SELECT SIZE="3" NAME="mcq">
                                       <OPTION SELECTED><%= aQsAns1 %></OPTION>
                                       <OPTION><%= aQsAns2 %></OPTION>
                                       <OPTION><%= aQsAns3 %></OPTION>
                                  </SELECT><BR><BR>
                             </TD>
                        </TR>
                        <TR>
                             <TD>
                                  <INPUT TYPE="submit" VALUE="Submit Your Answer">
                                  <INPUT TYPE="hidden" NAME="submitAns" VALUE="Submit Your Answer">
                             </TD>
                        </TR>
                   </TABLE>
                   </DIV>
              </FORM>
         </BODY>
    </HTML>
    This must be answered before 28th of september.
    Please help. It is indeed very urgent.

    this is just a skeleton code.. alot of stuff is not here..
    <FORM name = "form1" action="../servlet/wateverSevlet>
    <input type="text" name="searchStr" size="40">
    <INPUT type="hidden" id=answer name=answer size=7>
    <input type="button" name="button" value="Submit Answer" onClick="javascript:submitCheck(document.form1.searchStr.value);">
    <input type="button" name="button" value="Skip Question" onClick="javascript:submitCheck('skip');">
    </form>
    <SCRIPT LANGUAGE="JavaScript">
    function submitCheck(str)
      form1.answer.value = str
      form1.submit()
    </script>i assuming you are submitting it to the same servlet regardless of whether the user clicks the skip question or the submit question button.

  • Can display Web pages from servlet but not applet?

    I have been able to display real-world Web pages from a simple servlet using JDeveloper 3.0, but can't figure out how to do the same from an applet. Any hints?

    My previous post had the detail...Probably a simple question from a relative novice. I'm having a problem just viewing web pages by calling them from a "list" of URLs in an applet. I built an applet with a split pane that has a JTree on one side and an "HTML viewing pane" on the other. I can click JTree nodes to display local html files, but I don't understand how to display web pages from the Internet. Do I need something like HyperlinkListener to make the jump to "hyper-world"???

  • Setting fields on html page from servlet

    I have a HTML Page1 on ServerA that calls a servlet on ServerB. I want the servlet to load Page2 on ServerA and set fields on Page2.
    I know I can do so by using Redirect and passing parameters in the URL that can be loaded in the onLoad event of Page2 but I was wondering if there is some way I can cause the servlet to set the fields directly.
    I have looked a getRequestDispatcher("url").forward but it seems to me that the page being called would have to be on ServerB (the servlet's server). Am I correct? If not how do I get this to work? I have tried getRequestDispatcher("Page2").forward() and getRequestDispatcher("/Page2").forward() but neither seem to work. I assume because the pages are expected to be found on the servlet's server?

    thank you!
    I do put a bounch of System.out.println statements in it. one is just before the out.println("<html>") statement. another is before response.sendRedirect(). My program can print out each of the System.out.println(). but stop after that.I really do not know why!
    Sean

  • Get HTML source from servlet or strut action

    Hi, need ur help
    I would like to get the HTML source code after calling a URL, for example,
    Suppose a servlet will return a page hello.html, i would like to grap this HTML page source code in my servlet or strut action.
    How can i achieve this?
    Thanks

    This question does not make sense, because the Servlet is the thing that generates the HTML in the first place.
    If you want to view the HTML source of a given web page. Go to 'View'->'Source' in Internet Explorer.

  • Passing parameter from servlet to Javascript url

    Hi all,
    I want to pass the value of a selected option box in servlet as a parameter to a url in JavaScript.
    my java script code is :
    out.println("function reloadform() { ");
    out.println("alert('aacat');");
    out.println("location.href = 'http://localhost:8080/examples/servlet/frec1?aacatt=aacat';");
    out.println("}");
    and servlet code is :
    out.println("<td bgcolor=#F2F9FF> <select name=aacat size=1 style=font-size: 8pt; color: #666666; font-family: Verdana; border: 1 solid #666666 onChange= 'reloadform();'>");
    while (ra.next()==true) {
    String mycat=ra.getString("acat");
    String myasc=ra.getString("ascode");
    out.println(mycat+"<br>");
         out.println("<option value='"+mycat+"'><font face=verdana size=1>"+mycat+"</font></option>");
    Can anyone suggest me something on this ? Any Code reference will be highly appreciated.
    Thanks for any help in advance.
    savdeep.

    Please take care post the code in proper format...
    regarding the solution.. try something like..
    <select name=aacat size=1 style=font-size: 8pt; color: #666666; font-family: Verdana; border: 1 solid #666666 onChange= 'reloadform(this.options[this.selectedIndex].value);'>");also change the javascript code suitably

Maybe you are looking for

  • How to get to your files when your Time Capsule dies :(

    I am posting this here to help someone who cannot access a Time Machine backup because the backup was "corrupted" the <insert whatever obscure message that contains the word "sparsebundle" here> message appears the Time Machine won't open up your bac

  • No signal from audigy 2zs line out j

    Hey there....due to a virus, I recently had to format my dri've and reinstall XP and all my apps including software for my Audigy 2 ZS soundcard. Before the format I had my sound and video card connect to my TV to extend my PC display and audio to my

  • Can a guest stream music from his ipad to my apple tv 2nd gen?

    I assume he has to be logged into my network.  if so, can we choose his library w/out having to do so using the TV?  I only have apple tv connected to my audio receiver and not my tv.

  • KinectRegion class API not available for JavaScript

    Hi, Is there any equivalent to Microsoft.Kinect.Xaml.Controls namespace functionality for HTML5/JS?  I find the KinectRegion provides a very simple and direct way to add Kinect events to a standard Windows 8 store app. How can this be achieved with H

  • Trying to import drivers, anyone ever run across FOLDERS that are named with a .INF?

    I am using the excellent driver import script from http://blog.coretech.dk/kea/automate-importing-and-creating-drivers-packages-in-sccm-2012-r2/ to try and import drivers from Dell and HP. We got these drivers from the Dell driver CAB website, same w