Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

URL pattern

 
sruti vijay
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Im trying to display url in a specific pattern like below

http://localhost:8080/projectname/packagename/method/userid.format

whereby format can be json or xml.......
and when a specific userid is given d entire details of the user will be published....

but its shows resource not available..please help...

Thanks
Sruthi
 
Swastik Dey
Rancher
Posts: 1603
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe it needs some url mapping in deployment descriptor.
 
sruti vijay
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here is my snippet

@Produces("application/xml")
@Path("users")
@Singleton
public class UserResource {
private TreeMap<Integer, User> userMap = new TreeMap<Integer, User>();

public UserResource(){
User user=new User();
user.setBrand("Canyon River Blues");
user.setCategory("Women's");

@GET
@Produces({"text/plain", "application/xml", "application/json", "text/xml"})
public List<User> getCustomers() {
List<User> users = new ArrayList<User> ();
users.addAll(userMap.values());
return users;
}

@GET
@Path("/aham/user/{id}")
public User getbrowdedItems(@PathParam("id") int uId) {
return userMap.get(uId);
}



and d url im expecting is "http://localhost:8080/test/user/browsedItems/userId.format"
test is the project name
entity class name is user.

Thanks
Sruthi
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic