struts 1.3.8 trying to get the rendered output of a struts page from a plain servlet

2010-01-04 Thread Jason Novotny

Hi,

I have a plain vanilla servlet and I want to "include" via the 
RequestDispatcher mechanism the rendered output of a struts page. Here's 
the code I have:


ServletContext ctx = servletConfig.getServletContext();
  RequestDispatcher rd = 
ctx.getRequestDispatcher("/modules/foo/Home.do?myparam=value");

  if (rd != null) {

  StringWriter stringWriter = new StringWriter();
  MyResponse myresponse = new MyResponse(response, stringWriter);
  rd.include(request, myresponse);
  System.err.println(stringWriter.toString());

  }

I created MyResponse as a wrapper on ServletResponse that contains a 
buffer so I can pull out the contents. However, I'm not getting anything


Has anyone done this before? Or is there some easy way to do this?

Thanks, Jason


-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Displaying an image in JSP in struts+tiles project

2010-01-04 Thread Aruna Ponaka

Hi,

Am building an application in struts2 and tiles. My requirement is to
retrieve an image blob from mysql database and display the image in a jsp
using img tag as below..

img src="" 

Part of my struts.xml is as below:

 




 

 

My MyBytesResult class is:

public class MyBytesResult implements Result {

private static final long serialVersionUID = 1L;


public void execute(ActionInvocation invocation) throws Exception {

MyAction action = (MyAction) invocation.getAction();
HttpServletResponse response = 
ServletActionContext.getResponse();

response.setContentType("image/jpeg");
//response.setContentLength(action.getMyContentLength());

response.getOutputStream().write(action.getMyImageInBytes());
response.getOutputStream().flush();
}

}

And MyAction class is:

public class MyAction extends ActionSupport {

private static final long serialVersionUID = 1L;
Blob image = null;
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
byte[] imgData = null;
OutputStream o = null;
HttpServletResponse response = ServletActionContext.getResponse();
public String doDefault() {
System.out.println("doDefault()");
try {
  Class.forName("com.mysql.jdbc.Driver");
  con =
DriverManager.getConnection("jdbc:mysql://localhost:3306/project","root","pass");
  stmt = con.createStatement();
  rs = stmt.executeQuery("select * from books_tb where
category='General' order by publish_date desc");
  while (rs.next()) {
image = rs.getBlob(11);
imgData = 
image.getBytes(1,(int)image.length()); 
 } 
   }
catch (Exception e) {
  System.out.println(e.getMessage());
} 
return "myImageResult";
  }

  public byte[] getMyImageInBytes() { 
  System.out.println("getMyImageInBytes()");
  try{
  
  }
  catch (Exception e) {
  System.out.println(e.getMessage());
 
 } 
  return imgData;
  }

//  public String getMyContentType() { }
//  public String getMyContentDisposition() {}
//  public int getMyContentLength() { }
//  public int getMyBufferSize() { }

}

when i run the code the image is not displayed and I get an error saying
No result defined for action com.action.MyAction and result success

In struts.xml is I provide reslut name="success" and the jsp, it does not
throw an error but not displaying the image. However in any case it is not
going to MyAction.java. What could i do to rectify this?
Could provide you with required code if necessary..

Thanks,
Aruna 

-- 
View this message in context: 
http://old.nabble.com/Displaying-an-image-in-JSP-in-struts%2Btiles-project-tp27020146p27020146.html
Sent from the Struts - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Re: Accessing Static Constants from JSP in Struts 2.0.14

2010-01-04 Thread DavidZaz

I figured it out.

In myClass, I have an enum listing the different state values. My
AVAILABLE_STATES variable was placed inside the curly braces for the enum.
This inadvertently placed the AVAILABLE_STATES variable inside the enum and
caused Struts 2 to throw an error message.


DavidZaz wrote:
> 
> I'm trying to access a static constant from a JSP page in Struts 2.0.14,
> but it is not working.
> 
> My JSP page:
> 
> 
> 
> Java code:
> 
> package org.my.company;
> 
> import java.util.ArrayList;
> import java.util.List;
> 
> public Class myClass {
> 
> public static final List AVAILABLE_STATES = getStates();
> 
> public static final List getStates() {
> List states = new ArrayList();
> states.add("New York");
> return states;
> }
> 
> When I try to access my jsp page, I receive the following error message:
> 
> Caused by: tag 'select', field 'list': The requested list key
> '@org.my.company.mycl...@available_states' could not be resolved as a
> collection/array/map/enumeration/iterator type. Example: people or
> people.{name} - [unknown location]
> 
> Does anyone have any suggestion about what needs to be changed?
> 
> Thanks!
> 

-- 
View this message in context: 
http://old.nabble.com/Accessing-Static-Constants-from-JSP-in-Struts-2.0.14-tp27018870p27019067.html
Sent from the Struts - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Accessing Static Constants from JSP in Struts 2.0.14

2010-01-04 Thread DavidZaz

I'm trying to access a static constant from a JSP page in Struts 2.0.14, but
it is not working.

My JSP page:



Java code:

package org.my.company;

import java.util.ArrayList;
import java.util.List;

public Class myClass {

public static final List AVAILABLE_STATES = getStates();

public static final List getStates() {
List states = new ArrayList();
states.add("New York");
return states;
}

When I try to access my jsp page, I receive the following error message:

Caused by: tag 'select', field 'list': The requested list key
'@org.my.company.mycl...@available_states' could not be resolved as a
collection/array/map/enumeration/iterator type. Example: people or
people.{name} - [unknown location]

Does anyone have any suggestion about what needs to be changed?

Thanks!
-- 
View this message in context: 
http://old.nabble.com/Accessing-Static-Constants-from-JSP-in-Struts-2.0.14-tp27018870p27018870.html
Sent from the Struts - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Re: OT- Versioning in Struts

2010-01-04 Thread Paul Benedict
1 = Struts 1
2 = Struts 2

On Mon, Jan 4, 2010 at 10:06 AM, Balwinder Kumar
 wrote:
> Hi Paul,
>
> Thanks for insight.
>
> 2 = Major release version. This is the architecture number.
>
> Can you please tell me how exactly this architecture number is decided, I
> mean what kind of changes in architecture will actually call for a change in
> this number?
>
> Regards,
> Balwinder Kumar
>
> Paul Benedict wrote:
>>
>> The science is in the version format: 2.X.Y.Z
>>
>> 2 = Major release version. This is the architecture number.
>> X = Minor release version.
>> Y = Patch release version.
>> Z = Emergency patch release version. Not always needed.
>>
>> Paul
>>
>> On Sat, Jan 2, 2010 at 10:09 AM, Balwinder Kumar
>>  wrote:
>>
>>>
>>> Hi,
>>>
>>> I just wanted to know how the version of release in Struts is decided? Is
>>> there a scientific way that you guys follow to determine the version? If
>>> yes, what is the process?
>>>
>>> Regards,
>>> Balwinder Kumar
>>>
>>> -
>>> To unsubscribe, e-mail: dev-unsubscr...@struts.apache.org
>>> For additional commands, e-mail: dev-h...@struts.apache.org
>>>
>>>
>>>
>>
>>
>
>

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



RE: migration to tiles2 - put attribute into request scope?

2010-01-04 Thread Michael Heinen
I sent this tiles issue the wrong list.

Sorry for crossposting to struts and tiles.



BTW:

Got it working with an additional import statement:



Main.jsp




















main.jsp:

  


navigation.jsp



tiles2:













main.jsp:

  


navigation.jsp


How can I place the content of activeTab (here "ba") into request scope to make 
it accessible by other frameworks?
Currently the String "activeTab" is passed but I want to pass "ba".

Thanks,
Michael


Re: struts 2 validation error

2010-01-04 Thread Paweł Wielgus
Hi Rakesh,
use preparable interface and in prepare method initialize anything
that is necessary to show that page.

Best greetings,
Pawel Wielgus.

2010/1/4, Rakesh K nair :
>
> Hi
>
> In my struts2 jsp page there is a "selection list".I am populating the
> "list" from action class before rendering the page.I have some validation in
> the page.After submitting it calls the same page.If validation is successful
> it enters the action class and initializes the "list" , but if it is failure
> then it will go to "input" result from there to jsp page without entering
> action class then raising an null pointer exception.I need that "list" even
> if the validation fails.
>
> Please help me to get out of this problem
>
> expecting your kind interaction
>
> thanks in advance
>
> rakesh
> --
> View this message in context:
> http://old.nabble.com/struts-2-validation-error-tp27009670p27009670.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> -
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org