• 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 with login program

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
struct-config.xml

<struts-config>

<form-beans>

<form-bean name="loginForm"
type="app.LoginForm"/>

</form-beans>

<global-forwards>
<forward name="welcome"
path="/Welcome.do"/>

</global-forwards>


<action-mappings>
<action path="/Welcome"
forward="/pages/Home.jsp"/>

<action path="/login"
type="app.LoginAction"
name="loginForm"
scope="request"
validate="true"
input="/pages/Login.jsp">
<forward name="success"
path="/pages/success.jsp"/>
</action>

</action-mappings>

<controller
processorClass="org.apache.struts.tiles.TilesRequestProcessor"/>



<message-resources parameter="MessageResources" />


<plug-in className="org.apache.struts.tiles.TilesPlugin" >
<set-property property="definitions-config"
value="/WEB-INF/tiles-defs.xml" />

<set-property property="moduleAware" value="true" />
</plug-in>

</struts-config>
---------------------------------------------------
login.jsp

<%@ page language="java" pageEncoding="ISO-8859-1"%>
<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<HTML>
<HEAD>
<TITLE>Sign in, Please!</TITLE>
</HEAD>
<BODY>
<html:errors/>
<html:form action="/login">
<TABLE border="0" width="100%">
<TR>
<TH align="right"><FONT SIZE="5">Username:</FONT></TH>
<TD align="left"><html:text property="username"/></TD>
</TR>
<TR>
<TH align="right"><FONT SIZE="5">Password:</FONT></TH>
<TD align="left"><html:password property="password"/></TD>
</TR>
<TR>
<TD align="right"><html:submit/></TD>
<TD align="right"><html:reset/></TD>
</TR>
</TABLE>
</html:form>
</BODY>
</HTML>
--------------------------------------------------------------------------------------
success.jsp

<html>
<body>
<h1> successfully logged in</h1>
</body>
</html>
-------------------------------------------------------------------------------
login form

package app;

import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;

public final class LoginForm extends ActionForm {
private String password = null;
private String username = null;

public String getUsername() {
return (this.username);
}
public void setUsername(String username) {
this.username = username;
}

public String getPassword() {
return (this.password);
}
public void setPassword(String password) {
this.password = password;
}

}

}
---------------------------------------------------------------------
login action

package app;


import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
//import org.apache.struts.action.ActionServlet;

import app.dao.mydao.dao;


public final class LoginAction extends Action {

public boolean isUserLogin(String username, String password)
{
dao t2=new dao();
String pass=null;
try
{
pass=t2.select(username);
}
catch (SQLException e)
{
e.printStackTrace();
}

if (password.equals(pass))
return true;
else
return false;
}



public ActionForward perform(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {

String username = ((LoginForm) form).getUsername();
String password = ((LoginForm) form).getPassword();



boolean validated = false;
try
{
validated = isUserLogin(username,password);
}

catch (Exception e) {
ActionErrors errors = new ActionErrors();
errors.add(ActionErrors.GLOBAL_ERROR,
new ActionError("error.logon.connect"));
saveErrors(request,errors);
return (new ActionForward(mapping.getInput()));
}

return (mapping.findForward("success"));

}

}
------------------------------------------------
when i try to login it is not going to success.jsp page. instead it is showing me a blank page with url
http://localhost:8080/oxy/login.do

is there anything wrong in my program

 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please UseCodeTags when posting code or configuration. Unformatted code and configuration is unnecessarily difficult to read.

You can edit your post by using the button.

To answer your question, yes, if you're expecting output and your page is blank, something is probably wrong with your program.

Why are you using the TilesRequestProcessor if you're not using any Tiles?
 
theju nagral
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is the code

struct-config.xml

---------------------------------------------------
login.jsp

--------------------------------------------------------------------------------------
success.jsp

-------------------------------------------------------------------------------
login form

---------------------------------------------------------------------
login action

------------------------------------------------
when i try to login it is not going to success.jsp page. instead it is showing me a blank page with url
http://localhost:8080/oxy/login.do

is there anything wrong in my program

========================
i am using tiles in my program

 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you really not indent your code?
 
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

you are using struts 1.0, right?
check your server log file what it shows...
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic