*
The moose likes Struts and the fly likes which Struts tag? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "which Struts tag?" Watch "which Struts tag?" New topic
Author

which Struts tag?

Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
I have a login page with username and password .After entering the credentials , a click on login button in this page would take me to a jsp which has CreateProject button.

A click on this button would take me to another jsp which consists of a form. This form has a textField called projectCreator which should be set with the username of the user.

How can I set the user name in that textfield? what tag should i use, as scriplet in not the right way?
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9291
    
  17

There are many ways of doing this. Let's say that a session scoped attribute named "username" stores the username. Then to put that as a value in a textfield, you've gotta do just this

This will set the value of the username session attribute as the value of the textfield...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
galne vaibhav
Greenhorn

Joined: Nov 30, 2009
Posts: 9
you only have to follow struts way of doing it you have call the setter method of the textfield
for example
my field name:
private String txtDescription;

getter and setters
public String getTxtDescription() {
return txtDescription;
}
public void setTxtDescription(String txtDescription) {
this.txtDescription = txtDescription;
}



In targeted method

place one line

setTxtDescription(txtDescription);

reply if you want more detail.
Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
A delayed reply but yes I did that...

This is what I have,

LoginAction.java



My JSP...



Nothing is getting printed in the UI..

The output :-->
---------------------

projectCreator:emptyspace

If I remove theme="none" then,

In UI:
---------

projectCreator //line1
(textfield) //line2


what should be the changes??

Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
any takers, please???
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: which Struts tag?
 
Similar Threads
check if user has access to a specific page.
displaying user eneterd value on jsp page
Java for log in authentication? (looking for tutorial that applies to situation)
conditionally targetting the client frame based on Server(servlet) program
imp.- j_security_check authenticates .. but how to set session as well ..?